Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit be66db3

Browse files
authored
Ensure that we stop the run if we get an uncaught error. (#152)
Without this change it was typically necessary for the harness to timeout before the result would be reported. In some cases e.g. with explicit_done set, this would never happen, leading to the appearance of a hang.
1 parent 9bcd7df commit be66db3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

testharness.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,20 +2673,31 @@ policies and contribution forms [3].
26732673
var tests = new Tests();
26742674

26752675
var error_handler = function(e) {
2676+
if (tests.tests.length === 0 && !tests.allow_uncaught_exception) {
2677+
tests.set_file_is_test();
2678+
}
2679+
2680+
var stack;
2681+
if (e.error && e.error.stack) {
2682+
stack = e.error.stack;
2683+
} else {
2684+
stack = e.filename + ":" + e.lineno + ":" + e.colno;
2685+
}
2686+
26762687
if (tests.file_is_test) {
26772688
var test = tests.tests[0];
26782689
if (test.phase >= test.phases.HAS_RESULT) {
26792690
return;
26802691
}
2681-
test.set_status(test.FAIL, e.message, e.stack);
2692+
test.set_status(test.FAIL, e.message, stack);
26822693
test.phase = test.phases.HAS_RESULT;
26832694
test.done();
2684-
done();
26852695
} else if (!tests.allow_uncaught_exception) {
26862696
tests.status.status = tests.status.ERROR;
26872697
tests.status.message = e.message;
2688-
tests.status.stack = e.stack;
2698+
tests.status.stack = stack;
26892699
}
2700+
done();
26902701
};
26912702

26922703
addEventListener("error", error_handler, false);

0 commit comments

Comments
 (0)