diff options
author | Steve Fung <stevefung@google.com> | 2016-04-21 15:45:49 -0700 |
---|---|---|
committer | Steve Fung <stevefung@google.com> | 2016-04-21 15:47:28 -0700 |
commit | c761cac510660609037d145baf97e2a601d3ad09 (patch) | |
tree | 4ac89edc20bbf7bcac1ca9758c983206addb5c2f | |
parent | e0a19f04b0631c800390b12efb580eb46408abd8 (diff) | |
download | bdk-c761cac510660609037d145baf97e2a601d3ad09.tar.gz |
Set exit code when unit tests fail
When test_runner.py has any unit tests fail, exits with a non-zero
return code so that test_runner.py can be called from scripts.
Bug: 28321483
Test: Make a unit test fail. Checked the exit code.
Change-Id: Ib6a9a753d26cd00a4a8785193b03ebb76f7f1d98
-rw-r--r-- | cli/lib/test_runner.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cli/lib/test_runner.py b/cli/lib/test_runner.py index 0c86281..572fb05 100644 --- a/cli/lib/test_runner.py +++ b/cli/lib/test_runner.py @@ -18,6 +18,7 @@ import os +import sys import unittest @@ -25,4 +26,6 @@ if __name__ == '__main__': testsuite = unittest.TestLoader().discover( start_dir=os.path.dirname(__file__), pattern='*_unittest.py') - unittest.TextTestRunner(verbosity=1, buffer=True).run(testsuite) + ret = unittest.TextTestRunner(verbosity=1, buffer=True).run(testsuite) + if not ret.wasSuccessful(): + sys.exit(1) |