test: simplify test-worker-syntax-error
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: https://github.com/nodejs/node/pull/26144 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
85b95cc6a3
commit
584dc4893c
@ -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));
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user