From 5892f92caf7745a926e24f8e0f11f1ac0dbdb152 Mon Sep 17 00:00:00 2001 From: Hamilton Turner Date: Tue, 22 Jul 2014 14:01:01 -0400 Subject: [PATCH] Return non-zero if any test failed --- toolset/benchmark/benchmarker.py | 16 ++++++++++++---- toolset/run-tests.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/toolset/benchmark/benchmarker.py b/toolset/benchmark/benchmarker.py index 5333de8c412..60c9b03463d 100644 --- a/toolset/benchmark/benchmarker.py +++ b/toolset/benchmark/benchmarker.py @@ -488,10 +488,12 @@ def __run_tests(self, tests): log.info("__run_tests") log.debug("__run_tests with __name__ = %s",__name__) + error_happened = False if self.os.lower() == 'windows': log.info("Executing __run_tests on Windows") for test in tests: - self.__run_test(test) + if self.__run_test(test) != 0: + error_happened = True else: log.info("Executing __run_tests on Linux") for test in tests: @@ -534,7 +536,12 @@ def __run_tests(self, tests): pass subprocess.call("sudo pkill -SIGKILL -s %s" % test_process.pid, shell=True) log.handlers = [] # Clean up handlers left by __run_test + if test_process.exitcode != 0: + error_happened = True log.info("End __run_tests") + if error_happened: + return 1 + return 0 ############################################################ # End __run_tests @@ -645,7 +652,7 @@ def signal_term_handler(signal, frame): if self.__is_port_bound(test.port): self.__write_intermediate_results(test.name, "port %s is not available before start" % test.port) log.error(Header("Error: Port %s is not available, cannot start %s" % (test.port, test.name))) - return + return 1 result = test.start(log) if result != 0: @@ -654,7 +661,7 @@ def signal_term_handler(signal, frame): log.error("ERROR: Problem starting %s", test.name) log.error(Header("Stopped %s" % test.name)) self.__write_intermediate_results(test.name,"#start() returned non-zero") - return + return 1 log.info("Sleeping for %s", self.sleep) time.sleep(self.sleep) @@ -676,7 +683,7 @@ def signal_term_handler(signal, frame): if self.__is_port_bound(test.port): self.__write_intermediate_results(test.name, "port %s was not released by stop" % test.port) log.error(Header("Error: Port %s was not released by stop %s" % (test.port, test.name))) - return + return 1 log.info(Header("Stopped %s" % test.name)) time.sleep(5) @@ -701,6 +708,7 @@ def signal_term_handler(signal, frame): log.error("%s", e) log.error("%s", sys.exc_info()[:2]) log.debug("Subprocess Error Details", exc_info=True) + return 1 ############################################################ # End __run_test ############################################################ diff --git a/toolset/run-tests.py b/toolset/run-tests.py index 9b748ada774..fe9c095d99a 100755 --- a/toolset/run-tests.py +++ b/toolset/run-tests.py @@ -172,7 +172,7 @@ def main(argv=None): elif benchmarker.parse != None: benchmarker.parse_timestamp() else: - benchmarker.run() + return benchmarker.run() # Integrate uncaught exceptions into our logging system # Note: This doesn't work if the exception happens in a