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

[th/print-results-multiple] print_results: support printing multiple results #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 22 additions & 12 deletions print_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def parse_args() -> argparse.Namespace:
)
parser.add_argument(
"result",
type=str,
help="The JSON result file from TFT Flow test.",
nargs="+",
help="The JSON result file(s) from TFT Flow test.",
)
common.log_argparse_add_argument_verbose(parser)

Expand All @@ -67,28 +67,38 @@ def parse_args() -> argparse.Namespace:
return args


def main() -> None:
args = parse_args()
def process_file(result_file: str) -> bool:

tft_results = tftbase.TftResults.parse_from_file(args.result)
tft_results = tftbase.TftResults.parse_from_file(result_file)

group_success, group_fail = tft_results.group_by_success()

print(
f"There are {len(group_success)} passing flows.{' Details:' if group_success else ''}"
f"There are {len(group_success)} passing flows in {repr(result_file)}.{' Details:' if group_success else ''}"
)
print_tft_results(group_success)

if group_success:
print("\n\n", end="")

print(
f"There are {len(group_fail)} failing flows.{' Details:' if group_fail else ''}"
f"There are {len(group_fail)} failing flows in {repr(result_file)}.{' Details:' if group_fail else ''}"
)
print_tft_results(group_fail)

if group_fail:
print("Failures detected")
print()
return not group_fail


def main() -> None:
args = parse_args()

failed_files: list[str] = []

for result_file in args.result:
if not process_file(result_file):
failed_files.append(result_file)

print()
if failed_files:
print(f"Failures detected in {repr(failed_files)}")
sys.exit(1)

print("No failures detected in results")
Expand Down
Loading