From 76c2f4f46b071e7e8d84ec5eaff760811430ec07 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 15 Feb 2019 22:07:58 -0800 Subject: [PATCH] test: simplify test-worker-syntax-error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig --- test/parallel/test-worker-syntax-error.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js index 5c91eb2d251204..1c1fbf1c1ab3a0 100644 --- a/test/parallel/test-worker-syntax-error.js +++ b/test/parallel/test-worker-syntax-error.js @@ -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)); +}));