Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: nodejs/build#1318
  • Loading branch information
addaleax committed Jul 13, 2018
commit 0a8a6d2e61ddbea7aaf4082ae7d997d8b5c2456e
6 changes: 4 additions & 2 deletions test/parallel/test-worker-exit-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-worker-onmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down