From 42d045e1ee57154a1fc4087dc7a9b3ca7ce57bf5 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 21 Oct 2016 22:57:17 +0200 Subject: [PATCH 1/4] test: check that `process.execPath` is a realpath This test is only here to ensure consistent cross-platform behaviour. --- test/parallel/test-process-execpath.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/parallel/test-process-execpath.js diff --git a/test/parallel/test-process-execpath.js b/test/parallel/test-process-execpath.js new file mode 100644 index 00000000000000..77ba5fe0cab75a --- /dev/null +++ b/test/parallel/test-process-execpath.js @@ -0,0 +1,21 @@ +'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 (process.argv[2] === 'child') { + 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.status, 0); + assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`); +} From 4038272841c58c6978220b6c5fadc581cd832309 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 21 Oct 2016 23:27:11 +0200 Subject: [PATCH 2/4] =?UTF-8?q?[squash]=20add=20comment=20saying=20?= =?UTF-8?q?=E2=80=9CThe=20console.log()=20output=20is=20part=20of=20the=20?= =?UTF-8?q?test=20here.=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/parallel/test-process-execpath.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/parallel/test-process-execpath.js b/test/parallel/test-process-execpath.js index 77ba5fe0cab75a..eca95ba3b97b50 100644 --- a/test/parallel/test-process-execpath.js +++ b/test/parallel/test-process-execpath.js @@ -8,6 +8,7 @@ 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(); From c0e5fa6b383873246fa3cce8f368c9e9034becfc Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 21 Oct 2016 23:32:46 +0200 Subject: [PATCH 3/4] [squash] reorder asserts to get proper debug output on windows --- test/parallel/test-process-execpath.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-process-execpath.js b/test/parallel/test-process-execpath.js index eca95ba3b97b50..e67bac9c554cce 100644 --- a/test/parallel/test-process-execpath.js +++ b/test/parallel/test-process-execpath.js @@ -17,6 +17,7 @@ if (process.argv[2] === 'child') { fs.symlinkSync(process.execPath, symlinkedNode); const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']); - assert.strictEqual(proc.status, 0); + assert.strictEqual(proc.stderr.toString(), ''); assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`); + assert.strictEqual(proc.status, 0); } From de7c1613cd79c1dc29c8139f3a1720ed9c16a73a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 21 Oct 2016 23:58:48 +0200 Subject: [PATCH 4/4] [squash] skip test on windows --- test/parallel/test-process-execpath.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/parallel/test-process-execpath.js b/test/parallel/test-process-execpath.js index e67bac9c554cce..5ac8a3f2238a7c 100644 --- a/test/parallel/test-process-execpath.js +++ b/test/parallel/test-process-execpath.js @@ -7,6 +7,11 @@ 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);