From 72b2a567c4be1724bcc5a7d250c0bd6dfeb6f4cd Mon Sep 17 00:00:00 2001 From: Igor Klopov Date: Tue, 18 Apr 2017 09:54:55 +0300 Subject: [PATCH] conform https://github.com/nodejs/node/pull/11288 --- test/test-50-sigusr1/main.js | 2 +- test/utils.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test-50-sigusr1/main.js b/test/test-50-sigusr1/main.js index e60b1a469..0f3b04363 100644 --- a/test/test-50-sigusr1/main.js +++ b/test/test-50-sigusr1/main.js @@ -25,7 +25,7 @@ utils.pkg.sync([ right = utils.spawn.sync( './' + path.basename(output), [], - { cwd: path.dirname(output) } + { expect: null } ); assert.equal(right, 'ok\n'); diff --git a/test/utils.js b/test/utils.js index 50505d759..2fffe6f97 100644 --- a/test/utils.js +++ b/test/utils.js @@ -72,11 +72,13 @@ module.exports.spawn.sync = function (command, args, opts) { opts.stdio = [ d, d, d ]; } - const expect = opts.expect || 0; + let expect = opts.expect === undefined ? 0 : opts.expect; delete opts.expect; // to avoid passing to spawnSync - const opts2 = Object.assign({}, opts); // 0.12.x spoils + const opts2 = Object.assign({}, opts); // 0.12.x mutates const child = spawnSync(command, args, opts2); - const s = child.status; + let s = child.status; + // conform old node vers to https://github.com/nodejs/node/pull/11288 + if (child.signal) s = null; if (child.error || (s !== expect)) { if (opts.stdio[1] === 'pipe' && child.stdout) { @@ -92,6 +94,8 @@ module.exports.spawn.sync = function (command, args, opts) { throw child.error; } if (s !== expect) { + if (s === null) s = 'null'; + if (expect === null) expect = 'null'; throw new Error('Status ' + s.toString() + ', expected ' + expect.toString()); }