Commit ef1c7e05 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Continue running next test when async test throws error

Currently async tests end up timing out when they call assert
but don't catch the resulting exception and call done(true).

It seems more natural that when an async test has an assertion
failure, that the harness should catch the exception and take
care of continuing tests.

The alternative that async tests should catch there own errors
has the drawback that specific errors are not ever reported.
E.g. code below is bad.

testAsync(done) {
  try {
    assertEquals('foo', 'bar', 'foo should match bar');
    done();
  } catch  (err) {
    done(true)
  }
}

Bug: 813477
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Idbc88f94f6055eec37ab0d90b4b8d423fba6eb3f
Reviewed-on: https://chromium-review.googlesource.com/1088327Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564806}
parent ec29bf38
......@@ -205,6 +205,7 @@ function continueTesting(opt_asyncTestFailure) {
testName = testCases.pop();
console.log('TEST ' + testName + ' starting...');
var isAsyncTest = window[testName].length;
var testError = false;
try {
if (window.setUp)
window.setUp();
......@@ -214,9 +215,11 @@ function continueTesting(opt_asyncTestFailure) {
console.error('Failure in test ' + testName + '\n' + err);
console.log(err.stack);
cleanTestRun = false;
testError = true;
}
// Asynchronous tests must manually call continueTesting when complete.
if (!isAsyncTest)
// Asynchronous tests must manually call continueTesting when complete
// unless they throw an exception.
if (!isAsyncTest || testError)
continueTesting();
} else {
done = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment