test: fix timeouts when running worker tests with --worker
These tests have been added after the original workers PR and time out when run inside a worker by themselves. This is needed for enabling `--worker` tests in our regular CI. Refs: https://github.com/nodejs/build/issues/1318 PR-URL: https://github.com/nodejs/node/pull/21791 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
32cad739b1
commit
36cc5f5caf
@ -7,9 +7,11 @@ const common = require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
const worker = require('worker_threads');
|
||||
const { Worker, isMainThread, parentPort } = worker;
|
||||
const { Worker, parentPort } = worker;
|
||||
|
||||
if (isMainThread) {
|
||||
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
||||
if (!process.env.HAS_STARTED_WORKER) {
|
||||
process.env.HAS_STARTED_WORKER = 1;
|
||||
parent();
|
||||
} else {
|
||||
if (!parentPort) {
|
||||
|
@ -2,9 +2,11 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
||||
const { Worker, parentPort } = require('worker_threads');
|
||||
|
||||
if (isMainThread) {
|
||||
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
||||
if (!process.env.HAS_STARTED_WORKER) {
|
||||
process.env.HAS_STARTED_WORKER = 1;
|
||||
const w = new Worker(__filename);
|
||||
w.on('message', common.mustCall((message) => {
|
||||
assert.strictEqual(message, 4);
|
||||
|
Loading…
x
Reference in New Issue
Block a user