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

Call async test functions with await to better catch exceptions

Currently any exceptions thrown in an async test function are not caught
and the test will fail as a timeout.

Added fix for GalleryJsTest.ImageViewTest which was throwing exceptions
with undeclared metrics.record... functions.

TBR=fukino@chromium.org

Change-Id: I40ed5ff91a35ffd9a1c399d4d8405554e3fab911
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459136
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816044}
parent 16d6ce5d
......@@ -2,6 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// eslint-disable-next-line no-var
var metrics = {
recordEnum: function() {},
recordInterval: function() {},
startInterval: function() {}
};
function testImageView() {
const mockFileSystem = new MockFileSystem('volumeId');
const mockEntry = MockFileEntry.create(mockFileSystem, '/test.jpg');
......
......@@ -243,7 +243,7 @@ function startTesting() {
* @param {boolean=} opt_asyncTestFailure Optional parameter indicated if the
* last asynchronous test failed.
*/
function continueTesting(opt_asyncTestFailure) {
async function continueTesting(opt_asyncTestFailure) {
const now = performance.now();
if (testName) {
console.log(
......@@ -270,7 +270,7 @@ function continueTesting(opt_asyncTestFailure) {
testHarness.setUp();
}
pendingTearDown = testHarness.tearDown || null;
testScope[testName](continueTesting);
await testScope[testName](continueTesting);
} catch (err) {
console.error('Failure in test ' + testName + '\n' + err);
console.log(err.stack);
......
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