[devtools/qunit] Retain firefox process stdout to eventually print it
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 24 Oct 2016 10:08:36 +0200
changeset 11746 7cf5a915e2e9
parent 11745 f79dc500a4e7
child 11747 9a6a8a683728
[devtools/qunit] Retain firefox process stdout to eventually print it The bare RuntimeError that gets emitted upon timeout does not help much to diagnose the problem. Let's see if we can get more information from stdout by not dropping it.
cubicweb/devtools/qunit.py
--- a/cubicweb/devtools/qunit.py	Mon Oct 24 09:45:38 2016 +0200
+++ b/cubicweb/devtools/qunit.py	Mon Oct 24 10:08:36 2016 +0200
@@ -15,7 +15,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import os, os.path as osp
 import errno
@@ -72,12 +72,16 @@
                 return False, msg
             raise
 
+    @property
+    def log_file(self):
+        return osp.join(self._profile_dir, 'cwtest.log')
+
     def start(self):
         self.stop()
         cmd = self.firefox_cmd + ['-silent', '--profile', self._profile_dir,
                                   '-url', self._url]
-        with open(os.devnull, 'w') as fnull:
-            self._process = Popen(cmd, stdout=fnull, stderr=fnull)
+        with open(self.log_file, 'wb') as fout:
+            self._process = Popen(cmd, stdout=fout, stderr=STDOUT)
 
     def stop(self):
         if self._process is not None:
@@ -142,6 +146,8 @@
             error = False
 
             def runtime_error(*data):
+                with open(browser.log_file) as logf:
+                    print(logf.read())
                 raise RuntimeError(*data)
 
             while not error: