Add -f test flag to stop after first test failure

(Mocha has a 'bail' config flag that's supposed to do this, but it doesn't seem
to work when passed to mocha.setup() (maybe because we're setting a custom fail
handler?), so this just calls abort() on the runner manually.)
This commit is contained in:
Dan Stillman 2015-05-29 04:01:40 -04:00
parent 15252623d7
commit f3a6b41c1c
3 changed files with 18 additions and 3 deletions

View file

@ -22,7 +22,7 @@ function quit(failed) {
}
function Reporter(runner) {
var indents = 0, passed = 0, failed = 0;
var indents = 0, passed = 0, failed = 0, aborted = false;
function indent() {
return Array(indents).join(' ');
@ -61,10 +61,16 @@ function Reporter(runner) {
+ " " + test.title + "\n"
+ indent() + " " + err.toString() + " at\n"
+ indent() + " " + err.stack.replace("\n", "\n" + indent() + " ", "g"));
if (ZoteroUnit.bail) {
aborted = true;
runner.abort();
}
});
runner.on('end', function() {
dump(passed+"/"+(passed+failed)+" tests passed.\n");
dump(passed + "/" + (passed + failed) + " tests passed"
+ (aborted ? " -- aborting" : "") + "\n");
quit(failed != 0);
});
}