Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 979039 - handle errors in promises for child_process tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantell committed May 5, 2014
1 parent ad450b3 commit f62c452
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions test/test-child_process.js
Expand Up @@ -66,7 +66,7 @@ exports.testExecOptionsEnvironment = function (assert, done) {
'receives environment option');
done();
});
});
}).then(null, assert.fail);
};

exports.testExecOptionsTimeout = function (assert, done) {
Expand Down Expand Up @@ -104,7 +104,7 @@ exports.testExecOptionsTimeout = function (assert, done) {
child.off('close', closeHandler);
done();
}
});
}).then(null, assert.fail);
};

exports.testExecFileCallbackSuccess = function (assert, done) {
Expand All @@ -116,7 +116,7 @@ exports.testExecFileCallbackSuccess = function (assert, done) {
assert.equal(stdout.trim(), '--myargs -j -s'.trim(), 'passes in correct arguments');
done();
});
});
}).then(null, assert.fail);
};

exports.testExecFileCallbackError = function (assert, done) {
Expand All @@ -143,7 +143,7 @@ exports.testExecFileOptionsEnvironment = function (assert, done) {
'receives environment option');
done();
});
});
}).then(null, assert.fail);
};

exports.testExecFileOptionsTimeout = function (assert, done) {
Expand Down Expand Up @@ -181,7 +181,7 @@ exports.testExecFileOptionsTimeout = function (assert, done) {
child.off('close', closeHandler);
done();
}
});
}).then(null, assert.fail);
};

/**
Expand All @@ -204,7 +204,7 @@ exports.testExecFileOptionsMaxBufferLargeStdOut = function (assert, done) {
});
stdoutChild.on('exit', exitHandler);
stdoutChild.on('close', closeHandler);
});
}).then(null, assert.fail);

function exitHandler (code, signal) {
assert.equal(code, null, 'Exit code is null in exit handler');
Expand Down Expand Up @@ -239,7 +239,7 @@ exports.testExecFileOptionsMaxBufferLargeStdOErr = function (assert, done) {
});
stderrChild.on('exit', exitHandler);
stderrChild.on('close', closeHandler);
});
}).then(null, assert.fail);

function exitHandler (code, signal) {
assert.equal(code, null, 'Exit code is null in exit handler');
Expand Down Expand Up @@ -280,7 +280,7 @@ exports.testExecFileOptionsMaxBufferSmallStdOut = function (assert, done) {
});
stdoutChild.on('exit', exitHandler);
stdoutChild.on('close', closeHandler);
});
}).then(null, assert.fail);

function exitHandler (code, signal) {
// Sometimes the buffer limit is hit before the process closes successfully
Expand Down Expand Up @@ -331,7 +331,7 @@ exports.testExecFileOptionsMaxBufferSmallStdErr = function (assert, done) {
});
stderrChild.on('exit', exitHandler);
stderrChild.on('close', closeHandler);
});
}).then(null, assert.fail);

function exitHandler (code, signal) {
// Sometimes the buffer limit is hit before the process closes successfully
Expand Down Expand Up @@ -377,7 +377,7 @@ exports.testChildExecFileKillSignal = function (assert, done) {
assert.equal(err.signal, 'beepbeep', 'correctly used custom killSignal');
done();
});
});
}).then(null, assert.fail);
};

exports.testChildProperties = function (assert, done) {
Expand All @@ -390,8 +390,7 @@ exports.testChildProperties = function (assert, done) {
assert.ok(true, 'Windows environment does not have `pid`');
else
assert.ok(child.pid > 0, 'Child has a pid');
done();
});
}).then(done, assert.fail);
};

exports.testChildStdinStreamLarge = function (assert, done) {
Expand Down Expand Up @@ -509,7 +508,7 @@ exports.testSpawnOptions = function (assert, done) {

envChild.on('close', envClose);
cwdChild.on('close', cwdClose);
});
}).then(null, assert.fail);

function envClose () {
assert.equal(envStdout.trim(), 'my-value-test', 'spawn correctly passed in ENV');
Expand Down

0 comments on commit f62c452

Please sign in to comment.