Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
test: add a SharedArrayBuffer worker test
  • Loading branch information
codebytere committed Sep 2, 2021
commit 9ff558a547be7356d4a3686487e603478ab95b1b
17 changes: 17 additions & 0 deletions test/parallel/test-worker-no-sab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Flags: --no-harmony-sharedarraybuffer

'use strict';

const common = require('../common');
const assert = require('assert');
const { isMainThread, Worker } = require('worker_threads');

// Regression test for https://github.com/nodejs/node/issues/39717.

const w = new Worker(__filename);

w.on('exit', common.mustCall((status) => {
assert.strictEqual(status, 2);
}));

if (!isMainThread) process.exit(2);
Comment on lines +7 to +17
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { isMainThread, Worker } = require('worker_threads');
// Regression test for https://github.com/nodejs/node/issues/39717.
const w = new Worker(__filename);
w.on('exit', common.mustCall((status) => {
assert.strictEqual(status, 2);
}));
if (!isMainThread) process.exit(2);
const { Worker } = require('worker_threads');
// Regression test for https://github.com/nodejs/node/issues/39717.
// 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('exit', common.mustCall((status) => {
assert.strictEqual(status, 2);
}));
} else {
process.exit(2);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codebytere Are you ok if we commit this suggestion, run tests, check with @BridgeAR if they can then approve the PR,, and hopefully land? Or is there something about this suggestion that would make you reluctant to do that?