Skip to content
This repository was archived by the owner on Jan 28, 2020. It is now read-only.

Commit 05337ac

Browse files
committed
Exit with non-zero exit code on test failure
1 parent b3cfa05 commit 05337ac

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

bin/intern.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,18 @@ program
345345
process.on('SIGINT', function () {
346346
intern.kill('SIGINT');
347347
});
348+
349+
intern.on('close', function (code, signal) {
350+
if (process.exitCode == null) {
351+
process.exitCode = code != null ? code : cli.exitCodeForSignal(signal);
352+
}
353+
});
354+
355+
intern.on('error', function () {
356+
if (process.exitCode == null) {
357+
process.exitCode = 1;
358+
}
359+
});
348360
})
349361
.on('--help', function () {
350362
print([

lib/cli.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var exports = module.exports;
22

3+
var os = require('os');
4+
35
/**
46
* Ensures that a semver is contained in a range
57
*/
@@ -57,6 +59,13 @@ exports.enumArg = function (choices, val) {
5759
return val;
5860
};
5961

62+
/**
63+
* Get the exit code corresponding to a signal name
64+
*/
65+
exports.exitCodeForSignal = function (signalName) {
66+
return 128 + (os.constants.signals[signalName] || 0);
67+
};
68+
6069
/**
6170
* Prints a message to the console
6271
*/

0 commit comments

Comments
 (0)