Skip to content

Commit

Permalink
Return non-zero if any test failed
Browse files Browse the repository at this point in the history
  • Loading branch information
hamiltont committed Jul 22, 2014
1 parent 02af184 commit 5892f92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions toolset/benchmark/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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,"<setup.py>#start() returned non-zero")
return
return 1

log.info("Sleeping for %s", self.sleep)
time.sleep(self.sleep)
Expand All @@ -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)
Expand All @@ -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
############################################################
Expand Down
2 changes: 1 addition & 1 deletion toolset/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5892f92

Please sign in to comment.