diff options
author | Richard Lau <riclau@uk.ibm.com> | 2019-03-05 08:56:16 -0500 |
---|---|---|
committer | Richard Lau <riclau@uk.ibm.com> | 2019-03-07 11:09:30 -0500 |
commit | 82a256ac6740b7a6d29439af911b86a7a0b2e63f (patch) | |
tree | ae632a3f24dbe190c152ab3be517b98ec15033ae /test/parallel/test-cli-eval.js | |
parent | 76e67e98843978223a74b177f4e53411caf95516 (diff) | |
download | android-node-v8-82a256ac6740b7a6d29439af911b86a7a0b2e63f.tar.gz android-node-v8-82a256ac6740b7a6d29439af911b86a7a0b2e63f.tar.bz2 android-node-v8-82a256ac6740b7a6d29439af911b86a7a0b2e63f.zip |
test: fix tests so they work in worker threads
Use the `cwd` option for child_process instead of `process.chdir()` to
allow tests to work with worker threads.
PR-URL: https://github.com/nodejs/node/pull/26453
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-cli-eval.js')
-rw-r--r-- | test/parallel/test-cli-eval.js | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 7a2c7a82aa..3fd00e7cdb 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -34,9 +34,6 @@ const path = require('path'); const fixtures = require('../common/fixtures'); const nodejs = `"${process.execPath}"`; -if (!common.isMainThread) - common.skip('process.chdir is not available in Workers'); - if (process.argv.length > 2) { console.log(process.argv.slice(2).join(' ')); process.exit(0); @@ -98,16 +95,14 @@ child.exec(`${nodejs} --print "os.platform()"`, })); // Module path resolve bug regression test. -const cwd = process.cwd(); -process.chdir(path.resolve(__dirname, '../../')); child.exec(`${nodejs} --eval "require('./test/parallel/test-cli-eval.js')"`, + { cwd: path.resolve(__dirname, '../../') }, common.mustCall((err, stdout, stderr) => { assert.strictEqual(err.code, 42); assert.strictEqual( stdout, 'Loaded as a module, exiting with status code 42.\n'); assert.strictEqual(stderr, ''); })); -process.chdir(cwd); // Missing argument should not crash. child.exec(`${nodejs} -e`, common.mustCall((err, stdout, stderr) => { |