From 8e85f4e0bd0b1fbbf401686b85d7282f8991454d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 15 Nov 2012 10:15:01 +0100 Subject: [IMP] timeout discipline * Global timeout significantly increased to correctly handle e.g. db creation and teardown * Per-test timeout brought back down to 2s bzr revid: xmo@openerp.com-20121115091501-ys8opo0ccr3dq29h --- addons/web/static/src/js/testing.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/testing.js') diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index e124897f063..7686499b939 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -286,6 +286,7 @@ openerp.testing = {}; // Always execute tests asynchronously stop(); + var timeout; var teardown = function () { return opts.teardown(instance, $fixture, mock) }; @@ -302,8 +303,25 @@ openerp.testing = {}; + "number of assertions they expect"); } } - return $.when(result).pipe(teardown, teardown); + var d = $.Deferred(); + $.when(result).then(function () { + d.resolve.apply(d, arguments) + }, function () { + d.reject.apply(d, arguments); + }); + if (async || (result && result.then)) { + // async test can be either implicit async (rpc) or + // promise-returning + timeout = setTimeout(function () { + QUnit.config.semaphore = 1; + d.reject({message: "Test timed out"}); + }, 2000); + } + return d.pipe(teardown, teardown); }).always(function () { + if (timeout) { + clearTimeout(timeout); + } start(); }).fail(function (error) { if (options.fail_on_rejection === false) { @@ -320,6 +338,7 @@ openerp.testing = {}; } } + ok(false, "failed!") ok(false, message); }); }); -- cgit v1.2.3