[poppler] 2 commits - regtest/commands regtest/HTMLReport.py regtest/main.py regtest/poppler-regtest regtest/TestRun.py

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Dec 15 03:39:45 PST 2013


 regtest/HTMLReport.py               |    5 +++--
 regtest/TestRun.py                  |    2 ++
 regtest/commands/__init__.py        |    4 ++--
 regtest/commands/create-refs.py     |    2 ++
 regtest/commands/create-report.py   |    7 ++++++-
 regtest/commands/find-regression.py |    4 +++-
 regtest/commands/run-tests.py       |    6 ++++--
 regtest/main.py                     |    8 ++++----
 regtest/poppler-regtest             |    2 +-
 9 files changed, 27 insertions(+), 13 deletions(-)

New commits:
commit a43b4bf84fe4bde6649049685bf4ed6a682e8286
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Dec 15 11:59:57 2013 +0100

    regtest: Add a command line option to create-report command to not launch the browser

diff --git a/regtest/HTMLReport.py b/regtest/HTMLReport.py
index 85abd34..0655e99 100644
--- a/regtest/HTMLReport.py
+++ b/regtest/HTMLReport.py
@@ -263,7 +263,7 @@ class HTMLReport:
         except:
             raise
 
-    def create(self):
+    def create(self, launch_browser):
         html = "<html><body><a name='top'></a>"
         if self.config.backends:
             backends = [get_backend(name) for name in self.config.backends]
@@ -323,4 +323,5 @@ class HTMLReport:
         f.write(html)
         f.close()
 
-        subprocess.Popen(['xdg-open', report_index])
+        if launch_browser:
+            subprocess.Popen(['xdg-open', report_index])
diff --git a/regtest/commands/create-report.py b/regtest/commands/create-report.py
index 8e1ad05..e356cf9 100644
--- a/regtest/commands/create-report.py
+++ b/regtest/commands/create-report.py
@@ -40,6 +40,9 @@ class CreateReport(Command):
         parser.add_argument('-p', '--pretty-diff',
                             action = 'store_true', dest = 'pretty_diff', default = False,
                             help = 'Include pretty diff output')
+        parser.add_argument('-n', '--no-browser',
+                            action = 'store_false', dest = 'launch_browser', default = True,
+                            help = 'Do not launch a web browser with the results')
         parser.add_argument('tests')
 
     def run(self, options):
@@ -53,7 +56,7 @@ class CreateReport(Command):
             docs_dir = os.path.dirname(doc)
 
         report = HTMLReport(docs_dir, options['refs_dir'], options['out_dir'])
-        report.create()
+        report.create(options['launch_browser'])
 
         return 0
 
commit 113958276b96d7f1aab7042e1807a9970425d234
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Dec 15 11:48:51 2013 +0100

    regtest: Return an exist status code depending on whether the command succeeded

diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index 1b984c9..6aba62f 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -194,6 +194,8 @@ class TestRun:
 
         self._queue.join()
 
+        return int(self._n_passed != self._n_run)
+
     def summary(self):
         self.printer.printout_ln()
 
diff --git a/regtest/commands/__init__.py b/regtest/commands/__init__.py
index 86f58fd..78e1f6f 100644
--- a/regtest/commands/__init__.py
+++ b/regtest/commands/__init__.py
@@ -44,7 +44,7 @@ class Command:
 
     def execute(self, args):
         ns = self._parser.parse_args(args)
-        self.run(vars(ns))
+        return self.run(vars(ns))
 
     def run(self, options):
         raise NotImplementedError
@@ -68,7 +68,7 @@ def _get_command(command_name):
 def run(args):
     command_class = _get_command(args[0])
     command = command_class()
-    command.execute(args[1:])
+    return command.execute(args[1:])
 
 def print_help():
     import os
diff --git a/regtest/commands/create-refs.py b/regtest/commands/create-refs.py
index d559fb3..b8073d3 100644
--- a/regtest/commands/create-refs.py
+++ b/regtest/commands/create-refs.py
@@ -63,4 +63,6 @@ class CreateRefs(Command):
             refs.create_refs_for_file(os.path.basename(doc))
         get_printer().printout_ln("Refs created in %s" % (t.elapsed_str()))
 
+        return 0
+
 register_command('create-refs', CreateRefs)
diff --git a/regtest/commands/create-report.py b/regtest/commands/create-report.py
index f17aabe..8e1ad05 100644
--- a/regtest/commands/create-report.py
+++ b/regtest/commands/create-report.py
@@ -55,4 +55,6 @@ class CreateReport(Command):
         report = HTMLReport(docs_dir, options['refs_dir'], options['out_dir'])
         report.create()
 
+        return 0
+
 register_command('create-report', CreateReport)
diff --git a/regtest/commands/find-regression.py b/regtest/commands/find-regression.py
index 8f5f811..734d12a 100644
--- a/regtest/commands/find-regression.py
+++ b/regtest/commands/find-regression.py
@@ -68,11 +68,13 @@ class FindRegression(Command):
         doc = options['test']
         if not os.path.isfile(doc):
             get_printer().printerr("Invalid test %s: not a regulat file" % (doc))
-            return
+            return 1
 
         t = Timer()
         bisect = Bisect(options['test'], options['refs_dir'], options['out_dir'])
         bisect.run()
         get_printer().printout_ln("Tests run in %s" % (t.elapsed_str()))
 
+        return 0
+
 register_command('find-regression', FindRegression)
diff --git a/regtest/commands/run-tests.py b/regtest/commands/run-tests.py
index c5d87f9..29e7dfa 100644
--- a/regtest/commands/run-tests.py
+++ b/regtest/commands/run-tests.py
@@ -65,10 +65,12 @@ class RunTests(Command):
 
         tests = TestRun(docs_dir, options['refs_dir'], options['out_dir'])
         if doc == docs_dir:
-            tests.run_tests()
+            status = tests.run_tests()
         else:
-            tests.run_test(os.path.basename(doc))
+            status = tests.run_test(os.path.basename(doc))
         tests.summary()
         get_printer().printout_ln("Tests run in %s" % (t.elapsed_str()))
 
+        return status
+
 register_command('run-tests', RunTests)
diff --git a/regtest/main.py b/regtest/main.py
index 41ce454..59b178b 100644
--- a/regtest/main.py
+++ b/regtest/main.py
@@ -80,16 +80,16 @@ def main(args):
         c.threads = n_cpus - c.threads
 
     try:
-        commands.run(args)
+        return commands.run(args)
     except commands.UnknownCommandError:
         sys.stderr.write("Unknown command: %s\n" % (args[0]))
         commands.print_help()
-        sys.exit(1)
+        return 1
     except backends.UnknownBackendError as e:
         sys.stderr.write(str(e) + "\n")
         sys.stdout.write("Backends are: %s\n" % (", ".join([backend.get_name() for backend in backends.get_all_backends()])))
-        sys.exit(1)
+        return 1
 
 if __name__ == '__main__':
     import sys
-    main(sys.argv[1:])
+    sys.exit(main(sys.argv[1:]))
diff --git a/regtest/poppler-regtest b/regtest/poppler-regtest
index fb1e126..fd69bcf 100755
--- a/regtest/poppler-regtest
+++ b/regtest/poppler-regtest
@@ -3,4 +3,4 @@
 import sys
 import main
 
-main.main(sys.argv[1:])
+sys.exit(main.main(sys.argv[1:]))


More information about the poppler mailing list