Skip to content

Commit e05b4e2

Browse files
committed
Handle empty nightly pytest reports
1 parent e7ea1a1 commit e05b4e2

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/validation/tools/combine_reports.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ def parse_report_options(values: Iterable[str]) -> Dict[str, Path]:
6262
mapping: Dict[str, Path] = {}
6363
for value in values:
6464
if "=" not in value:
65-
raise ValueError(
66-
f"Invalid --report option '{value}'. Expected format NIC=PATH."
67-
)
65+
raise ValueError(f"Invalid --report option '{value}'. Expected format NIC=PATH.")
6866
nic, raw_path = value.split("=", 1)
6967
nic = nic.strip()
7068
if not nic:
@@ -99,22 +97,14 @@ def parse_report(path: Path) -> Dict[Tuple[str, str], str]:
9997
test_name = test_name_element.get_text(separator=" ", strip=True)
10098
else:
10199
title_element = test_details.select_one(".title")
102-
test_name = (
103-
title_element.get_text(separator=" ", strip=True)
104-
if title_element
105-
else "UNKNOWN"
106-
)
107-
108-
results[(file_path, test_name)] = STATUS_LABELS.get(
109-
status_token, STATUS_LABELS["unknown"]
110-
)
100+
test_name = title_element.get_text(separator=" ", strip=True) if title_element else "UNKNOWN"
101+
102+
results[(file_path, test_name)] = STATUS_LABELS.get(status_token, STATUS_LABELS["unknown"])
111103

112104
return results
113105

114106

115-
def build_dataframe(
116-
keys: Iterable[Tuple[str, str]], data: Dict[str, Dict[Tuple[str, str], str]]
117-
) -> pd.DataFrame:
107+
def build_dataframe(keys: Iterable[Tuple[str, str]], data: Dict[str, Dict[Tuple[str, str], str]]) -> pd.DataFrame:
118108
ordered_tests = sorted(set(keys), key=lambda item: (item[0], item[1]))
119109
rows = []
120110
nic_columns = list(data.keys())
@@ -156,9 +146,19 @@ def main() -> None:
156146
print(f"Parsed {len(parsed)} tests for {nic_name} from {report_path}")
157147

158148
if not all_keys:
159-
raise RuntimeError("No tests discovered across provided reports.")
160-
161-
df = build_dataframe(all_keys, parsed_data)
149+
print("Warning: No tests discovered across provided reports. Writing placeholder entry.")
150+
df = pd.DataFrame(
151+
[
152+
{
153+
"Test File": "-",
154+
"Test Case": "-",
155+
**{nic: DEFAULT_STATUS for nic in reports.keys()},
156+
"Comments": "No tests discovered across provided reports.",
157+
}
158+
]
159+
)
160+
else:
161+
df = build_dataframe(all_keys, parsed_data)
162162
output_path = args.output
163163
output_path.parent.mkdir(parents=True, exist_ok=True)
164164
df.to_excel(output_path, index=False)

0 commit comments

Comments
 (0)