diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-11-15 10:15:01 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-11-15 10:15:01 +0100 |
| commit | 8e85f4e0bd0b1fbbf401686b85d7282f8991454d (patch) | |
| tree | 62746b428bb574b40efc86d5692b24bb9709c068 /addons/web/static/src/js/testing.js | |
| parent | 5fb303f12fe30c007ef462679039ca25205d64e7 (diff) | |
[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
Diffstat (limited to 'addons/web/static/src/js/testing.js')
| -rw-r--r-- | addons/web/static/src/js/testing.js | 21 |
1 files changed, 20 insertions, 1 deletions
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); }); }); |
