[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
This commit is contained in:
parent
5fb303f12f
commit
8e85f4e0bd
|
@ -54,7 +54,7 @@ TESTING = Template(u"""<!DOCTYPE html>
|
|||
var oe_db_info = ${db_info};
|
||||
// List of modules, each module is preceded by its dependencies
|
||||
var oe_all_dependencies = ${dependencies};
|
||||
QUnit.config.testTimeout = 10000;
|
||||
QUnit.config.testTimeout = 5 * 60 * 1000;
|
||||
</script>
|
||||
</head>
|
||||
<body id="oe" class="openerp">
|
||||
|
|
|
@ -297,9 +297,11 @@ test architecture was not warned about asynchronous operations.
|
|||
|
||||
.. note::
|
||||
|
||||
Asynchronous test cases also have a 10 seconds timeout: if the
|
||||
test does not finish within 10 seconds, it will be considered
|
||||
failed. This pretty much always means the test will not resolve.
|
||||
Asynchronous test cases also have a 2 seconds timeout: if the test
|
||||
does not finish within 2 seconds, it will be considered
|
||||
failed. This pretty much always means the test will not
|
||||
resolve. This timeout *only* applies to the test itself, not to
|
||||
the setup and teardown processes.
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ class WebSuite(QUnitSuite):
|
|||
password=tools.config['admin_passwd'] or 'admin'),
|
||||
''
|
||||
])
|
||||
super(WebSuite, self).__init__(url, 20000)
|
||||
super(WebSuite, self).__init__(url, 50000)
|
||||
def run(self, result):
|
||||
if sql_db._Pool is not None:
|
||||
sql_db._Pool.close_all(sql_db.dsn(tools.config['db_name']))
|
||||
|
|
|
@ -85,6 +85,15 @@ openerp.testing.section('basic section', function (test) {
|
|||
});
|
||||
});
|
||||
|
||||
test('timeouting', {asserts: 1}, function () {
|
||||
var d = $.Deferred();
|
||||
setTimeout(function () {
|
||||
ok(true, "yeah");
|
||||
d.resolve('ok')
|
||||
}, 10000);
|
||||
return d.promise();
|
||||
});
|
||||
|
||||
test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) {
|
||||
var Model = new instance.web.Model('web_tests_demo.model');
|
||||
return Model.call('create', [{name: "Bob"}])
|
||||
|
|
Loading…
Reference in New Issue