[jhbuild/desktop-testing: 4/6] [ldtp] Add test and testone commands to run g-d-t



commit 5e57959e6e9c77c2effebd98cb2371bb0b1ec791
Author: John Carr <john carr unrouted co uk>
Date:   Tue May 19 11:11:40 2009 +0100

    [ldtp] Add test and testone commands to run g-d-t
---
 jhbuild/commands/__init__.py |    1 +
 jhbuild/commands/test.py     |   80 ++++++++++++++++++++++++++++++++++++++++++
 jhbuild/modtypes/__init__.py |    6 +++-
 3 files changed, 86 insertions(+), 1 deletions(-)

diff --git a/jhbuild/commands/__init__.py b/jhbuild/commands/__init__.py
index bd375c3..dcce7c0 100644
--- a/jhbuild/commands/__init__.py
+++ b/jhbuild/commands/__init__.py
@@ -79,3 +79,4 @@ def run(command, config, args):
 
 
 from jhbuild.commands import base
+from jhbuild.commands import test
diff --git a/jhbuild/commands/test.py b/jhbuild/commands/test.py
new file mode 100644
index 0000000..ed5e730
--- /dev/null
+++ b/jhbuild/commands/test.py
@@ -0,0 +1,80 @@
+# jhbuild - a build script for GNOME 1.x and 2.x
+# Copyright (C) 2009  Codethink Ltd.
+#
+#   test.py: the most common jhbuild commands
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#  Authors:
+#    John Carr <john carr unrouted co uk>
+
+from optparse import make_option
+
+import jhbuild.moduleset
+import jhbuild.frontends
+from jhbuild.errors import UsageError, FatalError
+from jhbuild.commands import Command, register_command
+
+
+class cmd_test(Command):
+    doc = N_('Run UI tests for all modules')
+
+    name = 'test'
+    usage_args = '[ options ... ] [ modules ... ]'
+
+    def __init__(self):
+        Command.__init__(self, [
+            make_option('-s', '--skip', metavar='MODULES',
+                        action='append', dest='skip', default=[],
+                        help=_('treat the given modules as up to date')),
+            make_option('-t', '--start-at', metavar='MODULE',
+                        action='store', dest='startat', default=None,
+                        help=_('start building at the given module')),
+            ])
+
+    def run(self, config, options, args):
+        for item in options.skip:
+            config.skip += item.split(',')
+
+        module_set = jhbuild.moduleset.load(config)
+        module_list = module_set.get_module_list(args or config.modules, config.skip)
+
+        # remove modules up to startat
+        if options.startat:
+            while module_list and module_list[0].name != options.startat:
+                del module_list[0]
+            if not module_list:
+                raise FatalError(_('%s not in module list') % options.startat)
+
+        build = jhbuild.frontends.get_buildscript(config, module_list)
+        return build.build(phases=['ldtp_test'])
+
+register_command(cmd_test)
+
+
+class cmd_testone(Command):
+    doc = N_('Run UI tests for specified modules')
+
+    name = 'testone'
+    usage_args = '[ options ... ] [ modules ... ]'
+
+    def run(self, config, options, args):
+        module_set = jhbuild.moduleset.load(config)
+        module_list = module_set.get_module_list(args)
+
+        build = jhbuild.frontends.get_buildscript(config, module_list)
+        return build.build(phases=['ldtp_test'])
+
+register_command(cmd_testone)
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index a722612..7a1e536 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -226,8 +226,12 @@ class Package:
             return True
         return False
 
+    def skip_ldtp_test(self, buildscript, last_phase):
+        # Skip running the ldtp tests if there arent any :P
+        return self.ldtp == None
+
     def do_ldtp_test(self, buildscript):
-        buildscript.set_action(_('Running %s UI tests') % self.name)
+        buildscript.set_action(_('Running UI tests'), self)
         self.ldtp.execute(buildscript)
 
     def xml_tag_and_attrs(self):



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