Skip to content

Commit

Permalink
test: make tests cwd-independent
Browse files Browse the repository at this point in the history
PR-URL: #12812
Reviewed-By: Alexey Orlenko <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
vsemozhetbyt authored and addaleax committed May 5, 2017
1 parent 94a120c commit f1d593c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-cli-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-chdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f1d593c

Please sign in to comment.