|
7 | 7 | parser = argparse.ArgumentParser(description="Check for unexpected test results based on an exclusion list.") |
8 | 8 | parser.add_argument("report_json", help="Path to the hive report JSON file.") |
9 | 9 | parser.add_argument("--exclusion", required=True, help="Path to the exclusion YAML file.") |
| 10 | +parser.add_argument("--ignored", required=True, help="Path to the ignored tests YAML file.") |
10 | 11 | args = parser.parse_args() |
11 | 12 |
|
12 | 13 | # Load hive JSON |
|
18 | 19 | exclusion_data = yaml.safe_load(file) |
19 | 20 | exclusions = exclusion_data.get(report['name'], []) |
20 | 21 |
|
| 22 | +# Load ignored tests YAML |
| 23 | +with open(args.ignored, 'r') as file: |
| 24 | + ignored_data = yaml.safe_load(file) |
| 25 | + ignored_tests = ignored_data.get(report['name'], []) |
| 26 | + |
21 | 27 | # Collect unexpected failures and passes |
22 | 28 | unexpected_failures = [] |
23 | 29 | unexpected_passes = [] |
| 30 | +ignored_results = {'passed': [], 'failed': []} |
24 | 31 |
|
25 | 32 | for test in report['testCases'].values(): |
26 | 33 | test_name = test['name'] |
27 | 34 | test_pass = test['summaryResult']['pass'] |
| 35 | + |
| 36 | + # Check if this is an ignored test |
| 37 | + if test_name in ignored_tests: |
| 38 | + # Track ignored test results for informational purposes |
| 39 | + if test_pass: |
| 40 | + ignored_results['passed'].append(test_name) |
| 41 | + else: |
| 42 | + ignored_results['failed'].append(test_name) |
| 43 | + continue # Skip this test - don't count it as unexpected |
| 44 | + |
| 45 | + # Check against expected failures |
28 | 46 | if test_name in exclusions: |
29 | 47 | if test_pass: |
30 | 48 | unexpected_passes.append(test_name) |
31 | 49 | else: |
32 | 50 | if not test_pass: |
33 | 51 | unexpected_failures.append(test_name) |
34 | 52 |
|
| 53 | +# Print summary of ignored tests if any were ignored |
| 54 | +if ignored_results['passed'] or ignored_results['failed']: |
| 55 | + print("Ignored Tests:") |
| 56 | + if ignored_results['passed']: |
| 57 | + print(f" Passed ({len(ignored_results['passed'])} tests):") |
| 58 | + for test in ignored_results['passed']: |
| 59 | + print(f" {test}") |
| 60 | + if ignored_results['failed']: |
| 61 | + print(f" Failed ({len(ignored_results['failed'])} tests):") |
| 62 | + for test in ignored_results['failed']: |
| 63 | + print(f" {test}") |
| 64 | + print() |
| 65 | + |
35 | 66 | # Check if there are any unexpected failures or passes and exit with error |
36 | 67 | if unexpected_failures or unexpected_passes: |
37 | 68 | if unexpected_failures: |
|
0 commit comments