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:
Rich Trott 2019-02-15 22:07:58 -08:00 committed by Anna Henningsen
parent 85b95cc6a3
commit 584dc4893c
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -3,15 +3,9 @@ const common = require('../common');
const assert = require('assert'); const assert = require('assert');
const { Worker } = require('worker_threads'); const { Worker } = require('worker_threads');
// Do not use isMainThread so that this test itself can be run inside a Worker. const w = new Worker('abc)', { eval: true });
if (!process.env.HAS_STARTED_WORKER) { w.on('message', common.mustNotCall());
process.env.HAS_STARTED_WORKER = 1; w.on('error', common.mustCall((err) => {
const w = new Worker('abc)', { eval: true }); assert.strictEqual(err.constructor, SyntaxError);
w.on('message', common.mustNotCall()); assert(/SyntaxError/.test(err));
w.on('error', common.mustCall((err) => { }));
assert.strictEqual(err.constructor, SyntaxError);
assert(/SyntaxError/.test(err));
}));
} else {
throw new Error('foo');
}