[jhbuild/desktop-testing] [ldtp] Add simple ldtp and dogtail support classes



commit 35255d1a0cbf06ba90d5c3c8b99647535cbc6b4c
Author: John Carr <john carr unrouted co uk>
Date:   Tue May 19 15:35:00 2009 +0100

    [ldtp] Add simple ldtp and dogtail support classes
---
 jhbuild/modtypes/__init__.py |    9 +++--
 jhbuild/utils/ldtp.py        |   68 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index bd6206d..aabfcc9 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -23,15 +23,16 @@ __all__ = [
     'register_module_type',
     'parse_xml_node',
     'Package',
-    'get_dependencies'
-    'get_branch'
+    'get_dependencies',
+    'get_branch',
+    'get_ldtp_helper',
     ]
 
 import os
 
 from jhbuild.errors import FatalError, CommandError, BuildStateError, SkipToEnd
 from jhbuild.utils.sxml import sxml
-from jhbuild.utils.ldtp import LDTPHelper
+from jhbuild.utils.ldtp import GDTHelper
 
 _module_types = {}
 def register_module_type(name, parse_func):
@@ -129,7 +130,7 @@ def get_ldtp_helper(node):
     if child.hasAttribute("application"):
         app = ldtpnode.getAttribute("application")
 
-    return LDTPHelper(app)
+    return GDTHelper(app)
 
 
 class Package:
diff --git a/jhbuild/utils/ldtp.py b/jhbuild/utils/ldtp.py
index 0294445..15ab758 100644
--- a/jhbuild/utils/ldtp.py
+++ b/jhbuild/utils/ldtp.py
@@ -20,20 +20,36 @@
 #  Authors:
 #    John Carr <john carr unrouted co uk>
 
-__all__ = [
-    'get_ldtp_helper',
-]
+# The LDTP and Dogtail helpers are inspired by the work done in GSOC on
+# testmodule.py by Prashanth Mohan.
 
+class TestingHelper(object):
 
-class LDTPHelper(object):
+    def execute(self, buildscript):
+        if not buildscript.config.noxvfb:
+            x = XvfbWrapper(buildscript.config.xvfbargs)
+            x.execute(self._execute, buildscript)
+        else:
+            self._execute(buildscript)
+
+
+class GDTHelper(TestingHelper):
     """
     Helper object for running gnome-destop-testing tests
+
+    gnome-desktop-testing is different to LDTP and dogtail in that we can
+    do 'desktop-testing -a gedit' to run just the gedit tests. And because
+    the tests are installable, we can easily add additional tests seperately
+    to the g-d-t repository.
+
+    Eventually we might be able to move the tests to the applications
+    themselves and even go as far as distros packaging them.
     """
 
     def __init__(self, application=None):
         self.application = application
 
-    def execute(self, buildscript):
+    def _execute(self, buildscript):
         testargs = ['desktop-testing']
 
         if self.application:
@@ -42,4 +58,46 @@ class LDTPHelper(object):
         buildscript.execute(testargs)
 
 
+class LDTPHelper(TestingHelper):
+    """
+    Helper object for running ldtprunner
+
+    For running ldtp tests we expect a directory of tests with a run.xml
+    specifying which tests to run. They are executed with ldtprunner.
+    """
+
+    def __init__(self, directory):
+        self.directory = directory
+
+    def _start_ldtp(self):
+        ldtp = subprocess.Popen('ldtp', shell=False)
+        time.sleep(1)
+        if ldtp.poll() != None:
+            raise FatalError(_("Unable to start ldtp"))
+        return ldtp
+
+    def _execute(self, buildscript):
+        ldtp = self._start_ldtp()
+        try:
+            buildscript.execute("ldtprunner run.xml", cwd=self.directory)
+        finally:
+            os.kill(ldtp.pid, signal.SIGINT)
+
+
+class DogtailHelper(TestingHelper):
+    """
+    Helper object for running dogtail tests
+
+    For dogtail, we expect a directory of tests as .py files. We run them
+    directly with python.
+    """
+
+    def __init__(self, directory):
+        self.directory = directory
+
+    def _execute(self, buildscript):
+        testcases = [f for f in os.listdir(self.directory) if f.endswith('.py')]
+        for testcase in testcases:
+            buildscript.execute('python %s' % testcase, cwd=self.directory)
+
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]