Skip to content

Commit

Permalink
Merge pull request #316 from mtreinish/fix-inprogress
Browse files Browse the repository at this point in the history
Fix inprogress test detection
  • Loading branch information
masayukig authored Sep 1, 2021
2 parents 7d655e4 + a09d24f commit 2889233
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stestr/subunit_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ def trace(stdin, stdout, print_failures=False, failonly=False,
print("\nNo tests were successful during the run", file=sys.stderr)
return 1
in_progress = get_stuck_in_progress()
if count_tests('status', '^inprogress$') > 0:
print("\nThe following tests exited without returning a status \n"
if in_progress:
print("\nThe following tests exited without returning a status\n"
"and likely segfaulted or crashed Python:", file=sys.stderr)
for test in in_progress:
print("\n\t* %s" % test, file=sys.stderr)
Expand Down
17 changes: 17 additions & 0 deletions stestr/tests/test_subunit_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ def test_trace_with_stuck_inprogress(self):
timestamp=dt.now(UTC))
stream.stopTestRun()
output.seek(0)
# capture stderr for test
stderr = io.StringIO()
sys_err = sys.stderr
sys.stderr = stderr

def restore_stderr():
sys.stderr = sys_err

self.addCleanup(restore_stderr)
stdin = io.TextIOWrapper(io.BufferedReader(output))
returncode = subunit_trace.trace(stdin, sys.stdout)
self.assertEqual(1, returncode)
stderr.seek(0)
expected = """
The following tests exited without returning a status
and likely segfaulted or crashed Python:
\t* test_segfault
"""
self.assertEqual(stderr.read(), expected)

0 comments on commit 2889233

Please sign in to comment.