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 <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 MylesBorins committed Jul 11, 2017
1 parent fff0e39 commit fc9e7a9
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
Expand Up @@ -94,7 +94,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
Expand Up @@ -73,13 +73,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
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 fc9e7a9

Please sign in to comment.