Fail if no tests were successfully executed
This commit adds another sanity check to ensure we didn't have a test run with just skipped tests. Change-Id: Ie4bd185c209d9e9230ca8a3f54e8a433e82d9c14
This commit is contained in:
parent
01fb487df1
commit
2a22826c58
@ -354,6 +354,12 @@ def main():
|
||||
print_fails(sys.stdout)
|
||||
if not args.no_summary:
|
||||
print_summary(sys.stdout, elapsed_time)
|
||||
|
||||
# NOTE(mtreinish): Ideally this should live in testtools streamSummary
|
||||
# this is just in place until the behavior lands there (if it ever does)
|
||||
if count_tests('status', '^success$') == 0:
|
||||
print("\nNo tests were successful during the run")
|
||||
exit(1)
|
||||
exit(0 if summary.wasSuccessful() else 1)
|
||||
|
||||
|
||||
|
BIN
os_testr/tests/sample_streams/all_skips.subunit
Normal file
BIN
os_testr/tests/sample_streams/all_skips.subunit
Normal file
Binary file not shown.
BIN
os_testr/tests/sample_streams/successful.subunit
Normal file
BIN
os_testr/tests/sample_streams/successful.subunit
Normal file
Binary file not shown.
@ -14,6 +14,8 @@
|
||||
# under the License.
|
||||
|
||||
from datetime import datetime as dt
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from ddt import data
|
||||
from ddt import ddt
|
||||
@ -59,3 +61,21 @@ class TestSubunitTrace(base.TestCase):
|
||||
}
|
||||
with patch.dict(subunit_trace.RESULTS, patched_res, clear=True):
|
||||
self.assertEqual(subunit_trace.run_time(), expected_result)
|
||||
|
||||
def test_return_code_all_skips(self):
|
||||
skips_stream = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'sample_streams/all_skips.subunit')
|
||||
p = subprocess.Popen(['subunit-trace'], stdin=subprocess.PIPE)
|
||||
with open(skips_stream, 'rb') as stream:
|
||||
p.communicate(stream.read())
|
||||
self.assertEqual(1, p.returncode)
|
||||
|
||||
def test_return_code_normal_run(self):
|
||||
regular_stream = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'sample_streams/successful.subunit')
|
||||
p = subprocess.Popen(['subunit-trace'], stdin=subprocess.PIPE)
|
||||
with open(regular_stream, 'rb') as stream:
|
||||
p.communicate(stream.read())
|
||||
self.assertEqual(0, p.returncode)
|
||||
|
Loading…
Reference in New Issue
Block a user