[libgxps] regtest: Return an exist status code depending on whether the command succeeded
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgxps] regtest: Return an exist status code depending on whether the command succeeded
- Date: Tue, 23 Jun 2015 17:25:21 +0000 (UTC)
commit ced6651a8ef36f2c1a926879d6e79b262fc6c085
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Tue Jun 23 18:45:48 2015 +0200
regtest: Return an exist status code depending on whether the command succeeded
regtest/TestRun.py | 2 ++
regtest/commands/__init__.py | 4 ++--
regtest/commands/create-refs.py | 2 ++
regtest/commands/create-report.py | 2 ++
regtest/commands/run-tests.py | 6 ++++--
regtest/gxps-regtest | 2 +-
regtest/main.py | 6 +++---
7 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index 95b558d..ce11fd9 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -181,6 +181,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 1ea49ef..89cba64 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/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/gxps-regtest b/regtest/gxps-regtest
index fb1e126..fd69bcf 100755
--- a/regtest/gxps-regtest
+++ b/regtest/gxps-regtest
@@ -3,4 +3,4 @@
import sys
import main
-main.main(sys.argv[1:])
+sys.exit(main.main(sys.argv[1:]))
diff --git a/regtest/main.py b/regtest/main.py
index a6a9c3d..302c5d2 100644
--- a/regtest/main.py
+++ b/regtest/main.py
@@ -74,12 +74,12 @@ def main(args):
config.threads = n_cpus - config.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
if __name__ == '__main__':
import sys
- main(sys.argv[1:])
+ sys.exit(main(sys.argv[1:]))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]