Merge "Fail if no tests were successfully executed"

This commit is contained in:
Jenkins 2015-12-17 18:33:40 +00:00 committed by Gerrit Code Review
commit a316fa98f8
4 changed files with 26 additions and 0 deletions

View File

@ -376,6 +376,12 @@ def main():
print_fails(sys.stdout) print_fails(sys.stdout)
if not args.no_summary: if not args.no_summary:
print_summary(sys.stdout, elapsed_time) 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) exit(0 if summary.wasSuccessful() else 1)

Binary file not shown.

Binary file not shown.

View File

@ -14,6 +14,8 @@
# under the License. # under the License.
from datetime import datetime as dt from datetime import datetime as dt
import os
import subprocess
from ddt import data from ddt import data
from ddt import ddt from ddt import ddt
@ -59,3 +61,21 @@ class TestSubunitTrace(base.TestCase):
} }
with patch.dict(subunit_trace.RESULTS, patched_res, clear=True): with patch.dict(subunit_trace.RESULTS, patched_res, clear=True):
self.assertEqual(subunit_trace.run_time(), expected_result) 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)