2016-10-21 22:57:17 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
2017-07-01 01:29:09 +02:00
|
|
|
if (common.isWindows)
|
|
|
|
common.skip('symlinks are weird on windows');
|
|
|
|
|
2016-10-21 22:57:17 +02:00
|
|
|
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 (process.argv[2] === 'child') {
|
|
|
|
// The console.log() output is part of the test here.
|
|
|
|
console.log(process.execPath);
|
|
|
|
} else {
|
2017-12-25 07:38:11 +01:00
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
tmpdir.refresh();
|
2016-10-21 22:57:17 +02:00
|
|
|
|
2017-12-25 07:38:11 +01:00
|
|
|
const symlinkedNode = path.join(tmpdir.path, 'symlinked-node');
|
2016-10-21 22:57:17 +02:00
|
|
|
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);
|
|
|
|
}
|