File: check_no_test_skipped.py

package info (click to toggle)
python-threadpoolctl 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 324 kB
  • sloc: python: 1,230; sh: 134; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Check tests are not skipped in every ci job"""

from __future__ import print_function

import os
import sys
import xml.etree.ElementTree as ET


base_dir = sys.argv[1]

# dict {test: result} where result is False if the test was skipped in every
# job and True otherwise.
always_skipped = {}

for name in os.listdir(base_dir):
    # all test result files are in /base_dir/jobs.*/ dirs
    if name.startswith("stage1."):
        print("> processing test result from job", name.replace("stage1", ""))
        print("  > tests skipped:")
        result_file = os.path.join(base_dir, name, "test-data.xml")
        root = ET.parse(result_file).getroot()

        # All tests are identified by the xml tag testcase.
        for test in root.iter("testcase"):
            test_name = test.attrib["name"]
            skipped = any(child.tag == "skipped" for child in test)
            if skipped:
                print("    -", test_name)
            if test_name in always_skipped:
                always_skipped[test_name] &= skipped
            else:
                always_skipped[test_name] = skipped

print("\n------------------------------------------------------------------\n")
fail = False
for test, skipped in always_skipped.items():
    if skipped:
        fail = True
        print(test, "was skipped in every job")

if fail:
    sys.exit(1)