Skip to content

Commit 3b4ec5f

Browse files
committed
test: check that process.execPath is a realpath
This test is only here to ensure consistent cross-platform behaviour. PR-URL: #9229 Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d5fa1d5 commit 3b4ec5f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const child_process = require('child_process');
5+
const path = require('path');
6+
const fs = require('fs');
7+
8+
assert.strictEqual(process.execPath, fs.realpathSync(process.execPath));
9+
10+
if (common.isWindows) {
11+
common.skip('symlinks are weird on windows');
12+
return;
13+
}
14+
15+
if (process.argv[2] === 'child') {
16+
// The console.log() output is part of the test here.
17+
console.log(process.execPath);
18+
} else {
19+
common.refreshTmpDir();
20+
21+
const symlinkedNode = path.join(common.tmpDir, 'symlinked-node');
22+
fs.symlinkSync(process.execPath, symlinkedNode);
23+
24+
const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']);
25+
assert.strictEqual(proc.stderr.toString(), '');
26+
assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`);
27+
assert.strictEqual(proc.status, 0);
28+
}

0 commit comments

Comments
 (0)