Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
igorklopov committed Apr 18, 2017
1 parent cfab090 commit 72b2a56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/test-50-sigusr1/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 7 additions & 3 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
}
Expand Down

0 comments on commit 72b2a56

Please sign in to comment.