Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse subunit_trace output/validation logic for load/run #333

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions stestr/commands/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,13 @@ def _load_case(
continue
start_times.append(test["timestamps"][0])
stop_times.append(test["timestamps"][1])
if not start_times or not stop_times:
sys.stderr.write("\nNo tests were successful during the run")

# This is not ideal, as it means if you use don't enter this if statement
# some errors aren't caught
if subunit_trace.print_full_output(
stdout, start_times, stop_times, post_fails=True, no_summary=False
):
return 1
start_time = min(start_times)
stop_time = max(stop_times)
elapsed_time = stop_time - start_time
subunit_trace.print_fails(stdout)
subunit_trace.print_summary(stdout, elapsed_time)
if not results.wasSuccessful(summary_result):
return 1
else:
Expand Down
22 changes: 11 additions & 11 deletions stestr/subunit_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,7 @@ def show_outcome(


def print_fails(stream):
"""Print summary failure report.

Currently unused, however there remains debate on inline vs. at end
reporting, so leave the utility function for later use.
"""
"""Print summary failure report."""
if not FAILS:
return
stream.write("\n==============================\n")
Expand Down Expand Up @@ -470,24 +466,29 @@ def trace(
for x in RESULTS[worker]
if x["timestamps"][1] is not None
]
if not start_times:
if print_full_output(stdout, start_times, stop_times, post_fails, no_summary):
return 1
return 0 if results.wasSuccessful(summary) else 1


def print_full_output(stdout, start_times, stop_times, post_fails, no_summary):
"""Print output plus edge case validation"""
if not start_times or count_tests("status", ".*") == 0:
print("The test run didn't actually run any tests", file=sys.stderr)
return 1

start_time = min(start_times)
stop_time = max(stop_times)
elapsed_time = stop_time - start_time

if count_tests("status", ".*") == 0:
print("The test run didn't actually run any tests", file=sys.stderr)
return 1
if post_fails:
print_fails(stdout)
if not no_summary:
print_summary(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:
if count_tests("status", "^xfail$") + count_tests("status", "^success$") == 0:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

figured this is easier to read than join the two regex

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's fine I think the regex would just be ^xfail|success$ or something like that, but this is definitely more legible.

print("\nNo tests were successful during the run", file=sys.stderr)
return 1
in_progress = get_stuck_in_progress()
Expand All @@ -500,7 +501,6 @@ def trace(
for test in in_progress:
print("\n\t* %s" % test, file=sys.stderr)
return 1
return 0 if results.wasSuccessful(summary) else 1


def main():
Expand Down