Skip to content

Commit e4b0d02

Browse files
committed
Badges: compute a fake 'all' tag, containing all tests
1 parent e8a70ca commit e4b0d02

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

cwltest/argparser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def arg_parser() -> argparse.ArgumentParser:
107107
parser.add_argument(
108108
"--badgedir",
109109
type=str,
110-
help="Create JSON badges and store them in this directory.",
110+
help="Create JSON badges, one for each tag (plus a computed 'all' tag) "
111+
" and store them in this directory.",
111112
)
112113

113114
try:

cwltest/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ def collect(self) -> Iterator[CWLItem]:
325325
"--cwl-badgedir",
326326
{
327327
"type": str,
328-
"help": "Create badge JSON files and store them in this directory.",
328+
"help": "Create badge JSON files, one for each tag (plus a computed "
329+
"'all' tag), and store them in this directory.",
329330
},
330331
),
331332
(

cwltest/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ def parse_results(
313313
"""
314314
Parse the results and return statistics and an optional report.
315315
316+
An additional tag named "all" will be computed, containing all the test
317+
results.
318+
316319
Returns the total number of tests, dictionary of test counts
317320
(total, passed, failed, unsupported) by tag, and a jUnit XML report.
318321
"""
@@ -334,7 +337,7 @@ def parse_results(
334337
else "cwltest:#{i + 1}"
335338
)
336339
total += 1
337-
tags = tests[i].get("tags", [])
340+
tags = tests[i].get("tags", []) + ["all"]
338341
for t in tags:
339342
ntotal[t] += 1
340343

tests/test_badgedir.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ def test_badgedir(tmp_path: Path) -> None:
5353
assert obj.get("color", "") == "yellow"
5454
assert (badgedir / "command_line_tool.md").exists()
5555

56+
all_tests = badgedir / "all.json"
57+
assert all_tests.exists()
58+
with open(all_tests) as file:
59+
obj = json.load(file)
60+
assert obj.get("subject", "") == "all"
61+
assert obj.get("status", "") == "0%"
62+
assert obj.get("color", "") == "yellow"
63+
assert (badgedir / "all.md").exists()
64+
5665

5766
def test_badgedir_report_with_baseuri(tmp_path: Path) -> None:
5867
badgedir = tmp_path / "badgedir"

0 commit comments

Comments
 (0)