Skip to content

Commit

Permalink
test: check that process.execPath is a realpath
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax committed Nov 16, 2016
1 parent b209a6e commit 89469c8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/parallel/test-process-execpath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');

assert.strictEqual(process.execPath, fs.realpathSync(process.execPath));

if (common.isWindows) {
common.skip('symlinks are weird on windows');
return;
}

if (process.argv[2] === 'child') {
// The console.log() output is part of the test here.
console.log(process.execPath);
} else {
common.refreshTmpDir();

const symlinkedNode = path.join(common.tmpDir, 'symlinked-node');
fs.symlinkSync(process.execPath, symlinkedNode);

const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']);
assert.strictEqual(proc.stderr.toString(), '');
assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`);
assert.strictEqual(proc.status, 0);
}

0 comments on commit 89469c8

Please sign in to comment.