Skip to content

Commit 0d62a02

Browse files
committed
Restore test ID in tree view outputs
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 8f5294b commit 0d62a02

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

9pm.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def slugify(text, lowercase=True):
218218
def prefix_name(name):
219219
global TEST_CNT
220220
TEST_CNT += 1
221-
return str(TEST_CNT).zfill(4) + "-" + slugify(name, lowercase=True)
221+
return str(TEST_CNT).zfill(4), slugify(name, lowercase=True)
222222

223223
def gen_name(filepath):
224224
return os.path.basename(filepath)
@@ -275,10 +275,14 @@ def parse_suite(suite_path, parent_suite_path, options, settings, name=None):
275275
suite_dirname = os.path.dirname(suite_path)
276276

277277
if name:
278-
suite['unix_name'] = prefix_name(name)
278+
uniq_id, uname = prefix_name(name)
279+
suite['uniq_id'] = uniq_id
280+
suite['unix_name'] = uniq_id + "-" + uname
279281
suite['name'] = name
280282
else:
281-
suite['unix_name'] = gen_unix_name(suite_path)
283+
uniq_id, uname = gen_unix_name(suite_path)
284+
suite['uniq_id'] = uniq_id
285+
suite['unix_name'] = uniq_id + "-" + uname
282286
suite['name'] = gen_name(suite_path)
283287

284288
if not os.path.isfile(suite_path):
@@ -311,10 +315,14 @@ def parse_suite(suite_path, parent_suite_path, options, settings, name=None):
311315
case = {}
312316

313317
if 'name' in entry:
314-
case['unix_name'] = prefix_name(entry['name'])
318+
uniq_id, uname = prefix_name(entry['name'])
319+
case['uniq_id'] = uniq_id
320+
case['unix_name'] = uniq_id + "-" + uname
315321
case['name'] = entry['name']
316322
else:
317-
case['unix_name'] = gen_unix_name(entry['case'])
323+
uniq_id, uname = gen_unix_name(entry['case'])
324+
case['uniq_id'] = uniq_id
325+
case['unix_name'] = uniq_id + "-" + uname
318326
case['name'] = gen_name(entry['case'])
319327

320328
case['outfile'] = gen_outfile(case['unix_name'])
@@ -367,9 +375,9 @@ def write_report_result_tree(file, includes, data, depth):
367375
string += f"{stars}"
368376
string += f" {resultfmt(test)}"
369377
if 'outfile' in test:
370-
string += f" <<output-{test['unix_name']},{test['name']}>>"
378+
string += f" <<output-{test['unix_name']},{test['uniq_id']} {test['name']}>>"
371379
else:
372-
string += f" {test['name']}"
380+
string += f" {test['uniq_id']} {test['name']}"
373381

374382
file.write(f"{string}\n")
375383

@@ -525,7 +533,9 @@ def write_github_result_tree(file, data, depth):
525533
}
526534
for test in data['suite']:
527535
mark = icon_map.get(test['result'], "")
528-
file.write("{}- {} : {}\n".format(' ' * depth, mark, test['name']))
536+
file.write("{}- {} : {} {}\n".format(' ' * depth, mark,
537+
test['uniq_id'],
538+
test['name']))
529539

530540
if 'suite' in test:
531541
write_github_result_tree(file, test, depth + 1)
@@ -537,7 +547,10 @@ def write_github_result(data):
537547

538548
def write_md_result_tree(file, data, depth):
539549
for test in data['suite']:
540-
file.write("{}- {} : {}\n".format(' ' * depth, test['result'].upper(), test['name']))
550+
file.write("{}- {} : {} {}\n".format(' ' * depth,
551+
test['result'].upper(),
552+
test['uniq_id'],
553+
test['name']))
541554

542555
if 'suite' in test:
543556
write_md_result_tree(file, test, depth + 1)
@@ -578,7 +591,7 @@ def print_result_tree(data, base):
578591
sign = "?"
579592
color = pcolor.yellow
580593

581-
print("{}{}{}{} {}{}".format(base, prefix, color, sign, test['name'], pcolor.reset))
594+
print("{}{}{}{} {} {}{}".format(base, prefix, color, sign, test['uniq_id'], test['name'], pcolor.reset))
582595

583596
if 'suite' in test:
584597
print_result_tree(test, nextbase)
@@ -837,7 +850,9 @@ def create_base_suite(args):
837850
else:
838851
test = {}
839852
test['case'] = fpath
840-
test['unix_name'] = gen_unix_name(filename)
853+
uniq_id, uname = gen_unix_name(filename)
854+
test['uniq_id'] = uniq_id
855+
test['unix_name'] = uniq_id + "-" + uname
841856
test['name'] = gen_name(filename)
842857
test['outfile'] = gen_outfile(test['unix_name'])
843858

0 commit comments

Comments
 (0)