Skip to content

Commit a01093d

Browse files
committed
Move process exit out of runner-display
To allow runner-display to be reused by browser-runner, it will need to call back with success or failure instead of exiting the process itself.
1 parent 0c92f20 commit a01093d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

test/runner

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,6 @@ if (argv.parser) {
104104
}
105105

106106
var runner = require('./runner-core')(modulesToRun);
107-
require('./runner-display')(runner, argv);
107+
require('./runner-display')(runner, argv, function (err) {
108+
process.exit(err ? 1 : 0);
109+
});

test/runner-display.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,22 @@ var runnerHandlers = {
147147
}
148148
console.log('TOTALS: %s failed; %s success', ratio, percent);
149149
console.log('TIME: %dms', duration);
150-
151-
if (passedTests !== totalTests) {
152-
process.exit(1);
153-
}
154-
155150
}
156151
};
157152

158-
module.exports = function (runner, args) {
153+
module.exports = function (runner, args, callback) {
159154
argv = args;
160155
start = new Date().getTime();
161156

162157
Object.keys(runnerHandlers).forEach(function (event) {
163158
runner.on(event, runnerHandlers[event]);
164159
});
160+
161+
runner.on('done', function () {
162+
if (passedTests !== totalTests) {
163+
callback(new Error(failedTests + ' failures'));
164+
} else {
165+
callback();
166+
}
167+
});
165168
};

0 commit comments

Comments
 (0)