Skip to content

Commit

Permalink
test: simplify test-worker-syntax-error
Browse files Browse the repository at this point in the history
Remove extraneous code from test-worker-syntax-error. Because the worker
is called with `eval: true`, there is no need to set an environment
variable indicating whether the worker has started and so on. The test
file is only ever executed by the main thread.

PR-URL: #26144
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Trott authored and rvagg committed Feb 28, 2019
1 parent dab3d71 commit 76c2f4f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/parallel/test-worker-syntax-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');

// 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('abc)', { eval: true });
w.on('message', common.mustNotCall());
w.on('error', common.mustCall((err) => {
assert.strictEqual(err.constructor, SyntaxError);
assert(/SyntaxError/.test(err));
}));
} else {
throw new Error('foo');
}
const w = new Worker('abc)', { eval: true });
w.on('message', common.mustNotCall());
w.on('error', common.mustCall((err) => {
assert.strictEqual(err.constructor, SyntaxError);
assert(/SyntaxError/.test(err));
}));

0 comments on commit 76c2f4f

Please sign in to comment.