[devtools] Use Xvfb to run firefox in js tests on posix platforms stable
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 13 Feb 2012 12:47:59 +0100
branchstable
changeset 8226 a3d3bdd46463
parent 8225 baf8c16cae95
child 8227 884405bf3621
[devtools] Use Xvfb to run firefox in js tests on posix platforms This way we don't require running tests under X.
debian/control
devtools/qunit.py
--- a/debian/control	Mon Feb 13 12:45:21 2012 +0100
+++ b/debian/control	Mon Feb 13 12:47:59 2012 +0100
@@ -126,7 +126,7 @@
 Architecture: all
 XB-Python-Version: ${python:Versions}
 Depends: ${misc:Depends}, ${python:Depends}, cubicweb-server (= ${source:Version}), cubicweb-web (= ${source:Version}), python-pysqlite2
-Suggests: w3c-dtd-xhtml
+Suggests: w3c-dtd-xhtml, xvfb
 Description: tests suite and development tools for the CubicWeb framework
  CubicWeb is a semantic web application framework.
  .
--- a/devtools/qunit.py	Mon Feb 13 12:45:21 2012 +0100
+++ b/devtools/qunit.py	Mon Feb 13 12:47:59 2012 +0100
@@ -70,13 +70,16 @@
         fnull = open(os.devnull, 'w')
         stdout = TemporaryFile()
         stderr = TemporaryFile()
+        self.firefox_cmd = ['firefox', '-no-remote']
+        if os.name == 'posix':
+            self.firefox_cmd = ['xvfb-run', '-a'] + self.firefox_cmd
         try:
             home = osp.expanduser('~')
             user = getlogin()
             assert os.access(home, os.W_OK), \
                    'No write access to your home directory, Firefox will crash.'\
                    ' Are you sure "%s" is a valid home  for user "%s"' % (home, user)
-            check_call(['firefox', '-no-remote', '-CreateProfile',
+            check_call(self.firefox_cmd + ['-CreateProfile',
                         '%s %s' % (self._profile_name, self._tmp_dir)],
                                   stdout=stdout, stderr=stderr)
         except CalledProcessError, cpe:
@@ -87,7 +90,7 @@
     def start(self, url):
         self.stop()
         fnull = open(os.devnull, 'w')
-        self._process = Popen(['firefox', '-no-remote', '-P', self._profile_name, url],
+        self._process = Popen(self.firefox_cmd + ['-P', self._profile_name, url],
                               stdout=fnull, stderr=fnull)
 
     def stop(self):