blob: 9708fdeace3a504a79d3281b9d7fa3efd92ff57d [file] [log] [blame]
Anders Roxell65be7682022-12-08 12:02:43 +01001#!/usr/bin/env python3
2import sys
3import re
4
5
6def slugify(line):
7 non_ascii_pattern = r"[^A-Za-z0-9_-]+"
8 line = re.sub(r"\[\d{1,5}\]", "", line)
9 return re.sub(
10 r"_-", "_", re.sub(r"(^_|_$)", "", re.sub(non_ascii_pattern, "_", line))
11 )
12
13
14tests = ""
15for line in sys.stdin:
16 if "# selftests: " in line:
17 tests = slugify(line.replace("\n", "").split("selftests:")[1])
18 elif re.search(r"^.*?not ok \d{1,5} ", line):
Mark Brown51737d52023-01-17 10:45:16 +000019 match = re.match(r"^.*?not ok [0-9]+ (.*?)$", line)
Anders Roxell65be7682022-12-08 12:02:43 +010020 ascii_test_line = slugify(re.sub("# .*$", "", match.group(1)))
Anders Roxell55110392023-01-03 09:06:27 +010021 output = f"{tests}_{ascii_test_line} fail"
Anders Roxell65be7682022-12-08 12:02:43 +010022 if f"selftests_{tests}" in output:
23 output = re.sub(r"^.*_selftests_", "", output)
24 print(f"{output}")
25 elif re.search(r"^.*?ok \d{1,5} ", line):
Mark Brown51737d52023-01-17 10:45:16 +000026 match = re.match(r"^.*?ok [0-9]+ (.*?)$", line)
Anders Roxell85a05ee2023-06-27 11:22:03 +020027 if "# skip" in match.group(1).lower():
28 ascii_test_line = slugify(re.sub("# skip", "", match.group(1).lower()))
Anders Roxell65be7682022-12-08 12:02:43 +010029 output = f"{tests}_{ascii_test_line} skip"
30 else:
31 ascii_test_line = slugify(match.group(1))
32 output = f"{tests}_{ascii_test_line} pass"
33 if f"selftests_{tests}" in output:
34 output = re.sub(r"^.*_selftests_", "", output)
35 print(f"{output}")