[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};
|
var oe_db_info = ${db_info};
|
||||||
// List of modules, each module is preceded by its dependencies
|
// List of modules, each module is preceded by its dependencies
|
||||||
var oe_all_dependencies = ${dependencies};
|
var oe_all_dependencies = ${dependencies};
|
||||||
QUnit.config.testTimeout = 10000;
|
QUnit.config.testTimeout = 5 * 60 * 1000;
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body id="oe" class="openerp">
|
<body id="oe" class="openerp">
|
||||||
|
|
|
@ -297,9 +297,11 @@ test architecture was not warned about asynchronous operations.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Asynchronous test cases also have a 10 seconds timeout: if the
|
Asynchronous test cases also have a 2 seconds timeout: if the test
|
||||||
test does not finish within 10 seconds, it will be considered
|
does not finish within 2 seconds, it will be considered
|
||||||
failed. This pretty much always means the test will not resolve.
|
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::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -286,6 +286,7 @@ openerp.testing = {};
|
||||||
|
|
||||||
// Always execute tests asynchronously
|
// Always execute tests asynchronously
|
||||||
stop();
|
stop();
|
||||||
|
var timeout;
|
||||||
var teardown = function () {
|
var teardown = function () {
|
||||||
return opts.teardown(instance, $fixture, mock)
|
return opts.teardown(instance, $fixture, mock)
|
||||||
};
|
};
|
||||||
|
@ -302,8 +303,25 @@ openerp.testing = {};
|
||||||
+ "number of assertions they expect");
|
+ "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 () {
|
}).always(function () {
|
||||||
|
if (timeout) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
}
|
||||||
start();
|
start();
|
||||||
}).fail(function (error) {
|
}).fail(function (error) {
|
||||||
if (options.fail_on_rejection === false) {
|
if (options.fail_on_rejection === false) {
|
||||||
|
@ -320,6 +338,7 @@ openerp.testing = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok(false, "failed!")
|
||||||
ok(false, message);
|
ok(false, message);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ class WebSuite(QUnitSuite):
|
||||||
password=tools.config['admin_passwd'] or 'admin'),
|
password=tools.config['admin_passwd'] or 'admin'),
|
||||||
''
|
''
|
||||||
])
|
])
|
||||||
super(WebSuite, self).__init__(url, 20000)
|
super(WebSuite, self).__init__(url, 50000)
|
||||||
def run(self, result):
|
def run(self, result):
|
||||||
if sql_db._Pool is not None:
|
if sql_db._Pool is not None:
|
||||||
sql_db._Pool.close_all(sql_db.dsn(tools.config['db_name']))
|
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) {
|
test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) {
|
||||||
var Model = new instance.web.Model('web_tests_demo.model');
|
var Model = new instance.web.Model('web_tests_demo.model');
|
||||||
return Model.call('create', [{name: "Bob"}])
|
return Model.call('create', [{name: "Bob"}])
|
||||||
|
|
Loading…
Reference in New Issue