0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-process-execpath.js
Vse Mozhet Byt 2d2986ae72 test: simplify test skipping
* Make common.skip() exit.

  Also add common.printSkipMessage() for partial skips.

* Don't make needless things before skip

PR-URL: https://github.com/nodejs/node/pull/14021
Fixes: https://github.com/nodejs/node/issues/14016
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-04 12:41:49 +03:00

27 lines
854 B
JavaScript

'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('symlinks are weird on windows');
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 {
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);
}