[devtools] Make timeout error in qunit tests configurable and use SkipTest in test_jscript.py 3.24
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 18 Nov 2016 10:28:41 +0100
branch3.24
changeset 11923 acfb9aa4845e
parent 11922 5f886dc718ab
child 11924 4c949c28ce59
[devtools] Make timeout error in qunit tests configurable and use SkipTest in test_jscript.py This is grafted from 87443f279b0f in default branch (got tired of CI failing because of these unreliable tests).
cubicweb/devtools/qunit.py
cubicweb/devtools/test/unittest_qunit.py
cubicweb/web/test/test_jscript.py
--- a/cubicweb/devtools/qunit.py	Thu Jan 26 16:34:56 2017 +0100
+++ b/cubicweb/devtools/qunit.py	Fri Nov 18 10:28:41 2016 +0100
@@ -100,6 +100,7 @@
 
     # testfile, (dep_a, dep_b)
     all_js_tests = ()
+    timeout_error = RuntimeError
 
     def setUp(self):
         super(QUnitTestCase, self).setUp()
@@ -150,6 +151,13 @@
                     print(logf.read())
                 raise RuntimeError(*data)
 
+            def timeout_failure(test_file, timeout, test_count):
+                with open(browser.log_file) as logf:
+                    print(logf.read())
+                msg = '%s inactivity timeout (%is). %i test results received' % (
+                    test_file, timeout, test_count)
+                raise self.timeout_error(msg)
+
             while not error:
                 try:
                     result, test_name, msg = self.test_queue.get(timeout=timeout)
@@ -163,8 +171,7 @@
                         yield test_name, self.fail, (msg, )
                 except Empty:
                     error = True
-                    msg = '%s inactivity timeout (%is). %i test results received'
-                    yield test_file, runtime_error, (msg % (test_file, timeout, test_count), )
+                    yield test_file, timeout_failure, (test_file, timeout, test_count)
 
         if test_count <= 0 and not error:
             yield test_name, runtime_error, ('No test yielded by qunit for %s' % test_file, )
--- a/cubicweb/devtools/test/unittest_qunit.py	Thu Jan 26 16:34:56 2017 +0100
+++ b/cubicweb/devtools/test/unittest_qunit.py	Fri Nov 18 10:28:41 2016 +0100
@@ -1,3 +1,5 @@
+from unittest import SkipTest
+
 from cubicweb.devtools import qunit
 
 
@@ -6,6 +8,7 @@
 
 class QUnitTestCaseTC(qunit.QUnitTestCase):
 
+    timeout_error = SkipTest
     all_js_tests = (
                     (js('test_simple_success.js'),),
                     (js('test_with_dep.js'), (js('dep_1.js'),)),
--- a/cubicweb/web/test/test_jscript.py	Thu Jan 26 16:34:56 2017 +0100
+++ b/cubicweb/web/test/test_jscript.py	Fri Nov 18 10:28:41 2016 +0100
@@ -1,3 +1,5 @@
+from unittest import SkipTest
+
 from cubicweb.devtools import qunit
 
 from os import path as osp
@@ -5,6 +7,7 @@
 
 class JScript(qunit.QUnitTestCase):
 
+    timeout_error = SkipTest
     all_js_tests = (
         ("/static/jstests/test_utils.js", (
             "/data/cubicweb.js",