Skip to content
Permalink
Browse files

test: make tests cwd-independent

PR-URL: #12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
vsemozhetbyt authored and addaleax committed May 3, 2017
1 parent 94a120c commit f1d593cda16dec18d56e76bedb11200d57e74e36
Showing with 5 additions and 1 deletion.
  1. +1 −1 test/doctool/test-doctool-html.js
  2. +3 −0 test/parallel/test-cli-eval.js
  3. +1 −0 test/parallel/test-process-chdir.js
@@ -105,7 +105,7 @@ testData.forEach((item) => {
{
input: preprocessed,
filename: 'foo',
template: 'doc/template.html',
template: path.resolve(__dirname, '../../doc/template.html'),
nodeVersion: process.version,
analytics: item.analyticsId,
},
@@ -94,13 +94,16 @@ 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')"`,
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) => {
@@ -5,6 +5,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');

process.chdir('..');
assert.notStrictEqual(process.cwd(), __dirname);
process.chdir(__dirname);
assert.strictEqual(process.cwd(), __dirname);

0 comments on commit f1d593c

Please sign in to comment.
You can’t perform that action at this time.