From 7c356b739bb0204050260c887072d2df08619324 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Tue, 19 Mar 2024 07:58:59 +0200 Subject: [PATCH] [ci] Add step to print filtered test result summary --- .github/workflows/run-webdriver-tests.yml | 5 +- tools/scripts/print-webdriver-json-results | 72 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 tools/scripts/print-webdriver-json-results diff --git a/.github/workflows/run-webdriver-tests.yml b/.github/workflows/run-webdriver-tests.yml index bba2b4da8..0f98f132d 100644 --- a/.github/workflows/run-webdriver-tests.yml +++ b/.github/workflows/run-webdriver-tests.yml @@ -66,4 +66,7 @@ jobs: python3 -m venv .venv . .venv/bin/activate pip install -r tools/scripts/webkitpy/requirements.txt - tools/scripts/run-webdriver-tests + tools/scripts/run-webdriver-tests --json-output=results.json + + - name: Test results + run: tools/scripts/print-webdriver-json-results ./results.json diff --git a/tools/scripts/print-webdriver-json-results b/tools/scripts/print-webdriver-json-results new file mode 100755 index 000000000..2cab29a9f --- /dev/null +++ b/tools/scripts/print-webdriver-json-results @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 + +import json + + +def print_test_results(results_file): + + # Read the results from the file + with open(results_file, "r") as file: + results = json.load(file) + + test_data = json.dumps(results, indent=4, sort_keys=True) + + processed_results = { + "errors": [], + "failures": [], + "passes": [], + "xpasses": [], + "xfails": [], + } + + for result in results["results"]: + for subtest in result["subtests"]: + entry = f"{result['test']}-{subtest['name']}" + if subtest["status"] == "ERROR": + processed_results["errors"].append(entry) + elif subtest["status"] == "FAIL": + processed_results["failures"].append(entry) + elif subtest["status"] == "PASS": + processed_results["passes"].append(entry) + elif subtest["status"] == "XPASS": + processed_results["xpasses"].append(entry) + elif subtest["status"] == "XFAIL": + processed_results["xfails"].append(entry) + + print("=============================== WebDriver Test Results ===============================") + print() + print("Unexpected errors: {}".format(len(processed_results["errors"]))) + print() + print("\n".join(f'{test}' for test in processed_results["errors"])) + print() + print("Unexpected failures: {}".format(len(processed_results["failures"]))) + print() + print("\n".join(f'{test}' for test in processed_results["failures"])) + print() + print("Unexpected passes: {}".format(len(processed_results["xpasses"]))) + print() + print("\n".join(f'{test}' for test in processed_results["xpasses"])) + print() + print("Tests that passed:: {}".format(len(processed_results["passes"]))) + print() + print("\n".join(f'{test}' for test in processed_results["passes"])) + print() + print("Tests that failed as expected: {}".format(len(processed_results["xfails"]))) + print() + print("\n".join(f'{test}' for test in processed_results["xfails"])) + print() + +def parse_args(): + import argparse + parser = argparse.ArgumentParser(description="Print WebDriver test results") + parser.add_argument("results", help="Path to the WebDriver test results file") + return parser.parse_args() + +def main(args): + # Format and print JSON content + print_test_results(args.results) + +# Example usage: +if __name__ == "__main__": + ARGS = parse_args() + main(ARGS)