test: make tests cwd-independent

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Vse Mozhet Byt authored and Myles Borins committed 2017-07-11 17:43:45 +01:00
1 parent fff0e39933
commit fc9e7a98ed
3 files changed
+5 -1

No files matched your search

+1 -1
View File
@@ -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,
},
+3
View File
@@ -73,6 +73,8 @@ 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);
@@ -80,6 +82,7 @@ child.exec(`${nodejs} --eval "require('./test/parallel/test-cli-eval.js')"`,
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) => {
+1
View File
@@ -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);