Skip to content

Commit 6e6216e

Browse files
committed
Update
[ghstack-poisoned]
1 parent ad41c6d commit 6e6216e

File tree

1 file changed

+18
-37
lines changed

1 file changed

+18
-37
lines changed

backends/test/suite/generate_markdown_summary_json.py

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def aggregate_results(json_path: str) -> AggregatedSummary:
8080

8181
test_id = subtest_meta["Test ID"]
8282
base_test = subtest_meta["Test Case"]
83-
params = test_id[base_test.len() + 1 : -1]
83+
params = test_id[len(base_test) + 1 : -1]
8484

8585
if params:
8686
if params not in counts_by_param:
@@ -135,49 +135,30 @@ def generate_markdown(json_path: str, exit_code: int = 0): # noqa (C901)
135135
if results.counts_by_params:
136136
print("\n## Results by Parameters\n")
137137

138-
# Extract all unique parameter keys from the JSON strings
139-
all_param_keys = set()
140-
parsed_params = {}
141-
142-
for params_str in results.counts_by_params.keys():
143-
# Parse the JSON string (it's a string representation of a dict)
144-
params_dict = json.loads(params_str)
145-
parsed_params[params_str] = params_dict
146-
all_param_keys.update(params_dict.keys())
147-
148-
if parsed_params and len(parsed_params) > 1:
149-
# Sort parameter keys for consistent column ordering
150-
sorted_param_keys = sorted(all_param_keys)
151-
138+
if len(results.counts_by_params) > 0:
152139
# Create table header
153-
header_cols = sorted_param_keys + ["Pass", "Fail", "Skip", "Pass %"]
140+
header_cols = ["Params", "Pass", "Fail", "Skip", "Pass %"]
154141
print("| " + " | ".join(header_cols) + " |")
155142
print("|" + "|".join(["---"] * len(header_cols)) + "|")
156143

157144
# Create table rows
158145
for params_str, counts in results.counts_by_params.items():
159-
if params_str in parsed_params:
160-
params_dict = parsed_params[params_str]
161-
row_values = []
162-
163-
# Add parameter values
164-
for key in sorted_param_keys:
165-
value = params_dict.get(key, "")
166-
row_values.append(str(value))
146+
row_values = [params_str]
167147

168-
pass_fraction = counts.passes / (counts.passes + counts.fails)
148+
# Add parameter values
149+
pass_fraction = counts.passes / (counts.passes + counts.fails)
169150

170-
# Add count values
171-
row_values.extend(
172-
[
173-
str(counts.passes),
174-
str(counts.fails),
175-
str(counts.skips),
176-
f"{pass_fraction*100:.2f}%",
177-
]
178-
)
151+
# Add count values
152+
row_values.extend(
153+
[
154+
str(counts.passes),
155+
str(counts.fails),
156+
str(counts.skips),
157+
f"{pass_fraction*100:.2f}%",
158+
]
159+
)
179160

180-
print("| " + " | ".join(row_values) + " |")
161+
print("| " + " | ".join(row_values) + " |")
181162

182163
print()
183164

@@ -231,12 +212,12 @@ def main():
231212
parser = argparse.ArgumentParser(
232213
description="Generate a Markdown representation of a test report."
233214
)
234-
parser.add_argument("csv_path", help="Path to the test report CSV file.")
215+
parser.add_argument("json_path", help="Path to the test report CSV file.")
235216
parser.add_argument(
236217
"--exit-code", type=int, default=0, help="Exit code from the test process."
237218
)
238219
args = parser.parse_args()
239-
generate_markdown(args.csv_path, args.exit_code)
220+
generate_markdown(args.json_path, args.exit_code)
240221

241222

242223
if __name__ == "__main__":

0 commit comments

Comments
 (0)