Skip to content

Commit a86433f

Browse files
vsemozhetbytgibfahn
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 fa3b4b3 commit a86433f

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
@@ -94,7 +94,7 @@ testData.forEach((item) => {
9494
{
9595
input: preprocessed,
9696
filename: 'foo',
97-
template: 'doc/template.html',
97+
template: path.resolve(__dirname, '../../doc/template.html'),
9898
nodeVersion: process.version,
9999
analytics: item.analyticsId,
100100
},

test/parallel/test-cli-eval.js

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

7575
// Module path resolve bug regression test.
76+
const cwd = process.cwd();
77+
process.chdir(path.resolve(__dirname, '../../'));
7678
child.exec(`${nodejs} --eval "require('./test/parallel/test-cli-eval.js')"`,
7779
common.mustCall((err, stdout, stderr) => {
7880
assert.strictEqual(err.code, 42);
7981
assert.strictEqual(
8082
stdout, 'Loaded as a module, exiting with status code 42.\n');
8183
assert.strictEqual(stderr, '');
8284
}));
85+
process.chdir(cwd);
8386

8487
// Missing argument should not crash.
8588
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)