0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/parallel/test-process-execpath.js
Anna Henningsen 89469c8953
test: check that process.execPath is a realpath
This test is only here to ensure consistent cross-platform behaviour.

PR-URL: https://github.com/nodejs/node/pull/9229
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-11-16 01:37:20 +01:00

29 lines
868 B
JavaScript

'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);
}