Skip to content

Commit 867cffd

Browse files
committed
test: fix tests on windows
Signed-off-by: Nad Alaba <37968805+nadalaba@users.noreply.github.com>
1 parent b2f6aa3 commit 867cffd

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

test/parallel/test-child-process-exec-any-shells-windows.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ cp.exec('where bash', common.mustCall((error, stdout) => {
6161
const lines = stdout.trim().split(/[\r\n]+/g);
6262
for (let i = 0; i < lines.length; ++i) {
6363
const bashPath = lines[i].trim();
64+
const bashPathLower = bashPath.toLowerCase();
65+
66+
const isWSLBash =
67+
bashPathLower.includes('windowsapps') ||
68+
bashPathLower.includes('\\system32\\bash.exe');
69+
6470
test(bashPath);
65-
testCopy(`bash_${i}.exe`, bashPath);
71+
// Skip WSL bash (cannot be symlinked)
72+
if (!isWSLBash) testCopy(`bash_${i}.exe`, bashPath);
6673
}
6774
}));

test/parallel/test-snapshot-typescript.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ const { spawnSync } = require('child_process');
99
const tmpdir = require('../common/tmpdir');
1010
const fixtures = require('../common/fixtures');
1111
const fs = require('fs');
12+
const os = require('os');
1213

1314
tmpdir.refresh();
1415
const blobPath = tmpdir.resolve('snapshot.blob');
1516

1617
// Concat test/fixtures/snapshot/typescript.js with
17-
// test/fixtures/snapshot/typescript.js into
18+
// test/fixtures/snapshot/typescript-main.js into
1819
// tmpdir/snapshot.js.
1920
const file = tmpdir.resolve('snapshot.js');
2021
fs.copyFileSync(fixtures.path('snapshot', 'typescript.js'), file);
@@ -57,7 +58,8 @@ fs.appendFileSync(file,
5758

5859
assert.strictEqual(child.status, 0);
5960
const result = fs.readFileSync(outPath, 'utf8');
60-
const expected = fs.readFileSync(
61-
fixtures.path('snapshot', 'ts-example.js'), 'utf8');
61+
const expected = fs
62+
.readFileSync(fixtures.path('snapshot', 'ts-example.js'), 'utf8')
63+
.replace(/\r?\n/g, os.EOL);
6264
assert.strictEqual(result, expected);
6365
}

0 commit comments

Comments
 (0)