Skip to content

Commit f1d593c

Browse files
vsemozhetbytaddaleax
authored andcommitted
test: make tests cwd-independent
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]>
1 parent 94a120c commit f1d593c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

test/doctool/test-doctool-html.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ testData.forEach((item) => {
105105
{
106106
input: preprocessed,
107107
filename: 'foo',
108-
template: 'doc/template.html',
108+
template: path.resolve(__dirname, '../../doc/template.html'),
109109
nodeVersion: process.version,
110110
analytics: item.analyticsId,
111111
},

test/parallel/test-cli-eval.js

+3
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ child.exec(`${nodejs} --print "os.platform()"`,
9494
}));
9595

9696
// Module path resolve bug regression test.
97+
const cwd = process.cwd();
98+
process.chdir(path.resolve(__dirname, '../../'));
9799
child.exec(`${nodejs} --eval "require('./test/parallel/test-cli-eval.js')"`,
98100
common.mustCall((err, stdout, stderr) => {
99101
assert.strictEqual(err.code, 42);
100102
assert.strictEqual(
101103
stdout, 'Loaded as a module, exiting with status code 42.\n');
102104
assert.strictEqual(stderr, '');
103105
}));
106+
process.chdir(cwd);
104107

105108
// Missing argument should not crash.
106109
child.exec(`${nodejs} -e`, common.mustCall((err, stdout, stderr) => {

test/parallel/test-process-chdir.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const assert = require('assert');
55
const fs = require('fs');
66
const path = require('path');
77

8+
process.chdir('..');
89
assert.notStrictEqual(process.cwd(), __dirname);
910
process.chdir(__dirname);
1011
assert.strictEqual(process.cwd(), __dirname);

0 commit comments

Comments
 (0)