diff options
| author | Christophe Matthieu <chm@openerp.com> | 2014-02-07 08:47:45 +0100 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2014-02-07 08:47:45 +0100 |
| commit | 4663f5b10ca78a2acbbffbbd8d68f7893e1d2f54 (patch) | |
| tree | 9cfbd561598c39eb68e3d16f8be44c333ddd36bb /addons/website/tests | |
| parent | 062c4914889497f4c9219da0870dd250bf901828 (diff) | |
[IMP] website test: add a timeout in phantom js to raise a better error and improve log error
bzr revid: chm@openerp.com-20140207074745-ffrcoi2aj5m67i8m
Diffstat (limited to 'addons/website/tests')
| -rw-r--r-- | addons/website/tests/test_ui.py | 2 | ||||
| -rw-r--r-- | addons/website/tests/ui_suite/ui_test_runner.js | 33 |
2 files changed, 16 insertions, 19 deletions
diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index a9c807689da..3c30dc8a762 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -41,7 +41,7 @@ class WebsiteUiSuite(unittest.TestSuite): # timeout in seconds def __init__(self, testfile, options, timeout=60.0): self._testfile = testfile - self._timeout = timeout + self._timeout = timeout + 5.0 self._options = options self._test = None self._ignore_filters = [ diff --git a/addons/website/tests/ui_suite/ui_test_runner.js b/addons/website/tests/ui_suite/ui_test_runner.js index dd023ee8081..f759ea69572 100644 --- a/addons/website/tests/ui_suite/ui_test_runner.js +++ b/addons/website/tests/ui_suite/ui_test_runner.js @@ -20,11 +20,9 @@ function waitFor (ready, callback, timeout, timeoutMessageCallback) { } function run (test, onload, inject) { - try { - var options = JSON.parse(phantom.args); - var timeout = options.timeout ? Math.round(parseFloat(options.timeout)*1000) : 60000; + var timeout = options.timeout ? Math.round(parseFloat(options.timeout)*1000-5000) : 60000; var scheme = options.scheme ? options.scheme+'://' : 'http://'; var host = options.host ? options.host : 'localhost'; @@ -96,14 +94,14 @@ function run (test, onload, inject) { var maxRetries = 10; var retryDelay = 1000; // ms - var tries = 0; + var tries = 0; page.open(url, function openPage (status) { if (status !== 'success') { tries++; if (tries < maxRetries) { - setTimeout(function () { - page.open(url, openPage); - }, retryDelay); + setTimeout(function () { + page.open(url, openPage); + }, retryDelay); } else { console.log('{ "event": "error", "message": "'+url+' failed to load '+tries+' times ('+status+')"}'); phantom.exit(1); @@ -116,15 +114,19 @@ function run (test, onload, inject) { }); - } catch (e) { - console.error("Error in run:", e); - phantom.exit(1); - } + setTimeout(function () { + page.evaluate(function (timeout) { + var message = ("Timeout after " +(timeout/1000)+ " s" + + "\nhref: " + window.location.href + + "\nreferrer: " + document.referrer + + "\n\n" + document.body.innerHTML).replace(/[^a-z0-9\s~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "*"); + console.log(JSON.stringify({ "event": "error", "message": message})); + phantom.exit(1); + },timeout); + }, timeout); } function run_test (testname, options) { - try { - options = options || {}; run( function start (page, timeout) { @@ -146,11 +148,6 @@ function run_test (testname, options) { }, options.inject || null ); - - } catch (e) { - console.error("Error in run_test:", e); - phantom.exit(1); - } } module.exports = { |
