Skip to content

Commit

Permalink
[ci] Add step to print filtered test result summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Hautakangas committed Mar 19, 2024
1 parent bd8ac5e commit 7c356b7
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/run-webdriver-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
72 changes: 72 additions & 0 deletions tools/scripts/print-webdriver-json-results
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7c356b7

Please sign in to comment.