ra8-firmware
0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
list_tests.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
# SPDX-License-Identifier: MIT
3
# Copyright (c) 2026 Brighton Sikarskie
4
"""List test targets belonging to one repository domain."""
5
6
import
re
7
import
sys
8
from
pathlib
import
Path
9
10
REPO_ROOT = Path(__file__).resolve().parents[2]
11
MIN_ARGUMENTS = 2
12
TEST_SUFFIXES = (
"c"
,
"cpp"
)
13
NAME_COLUMN_WIDTH = 40
14
CATEGORY_PATTERNS = {
15
"shared"
: (
"apps/shared_libs/*/tests"
,),
16
"host"
: (
"apps/host/*/tests"
,),
17
"board"
: (
"apps/board/*/*/tests"
,
"apps/board/*/tests"
),
18
"tools"
: (
"tools/*/tests"
,),
19
}
20
21
22
def
_search_patterns(category: str) -> tuple[str, ...]:
23
"""Return relative glob roots for one test category."""
24
return
CATEGORY_PATTERNS.get(category, (f
"tests/{category}"
,))
25
26
27
def
main
() -> None:
28
"""Print the tests discovered for the requested category."""
29
if
len(sys.argv) < MIN_ARGUMENTS:
30
print(
"Usage: list_tests.py <category>"
)
31
sys.exit(1)
32
33
category = sys.argv[1].lower()
34
35
search_patterns = _search_patterns(category)
36
37
tests: list[tuple[str, str]] = []
38
for
search_pattern
in
search_patterns:
39
for
suffix
in
TEST_SUFFIXES:
40
for
path
in
REPO_ROOT.glob(f
"{search_pattern}/test_*.{suffix}"
):
41
test_name = path.stem
42
43
# extract brief
44
desc = f
"{test_name} unit tests"
45
with
path.open(encoding=
"utf-8"
, errors=
"ignore"
)
as
handle:
46
for
source_line
in
handle:
47
match = re.search(
r"@brief\s+(.*)"
, source_line)
48
if
match:
49
desc = match.group(1).strip()
50
break
51
52
tests.append((test_name, desc))
53
54
tests.sort(key=
lambda
item: item[0])
55
56
if
not
tests:
57
print(f
"Error: Category '{category}' not found or has no tests."
)
58
sys.exit(1)
59
60
print(
61
f
"== {category.upper()} TESTS ({len(tests)}) -- "
62
f
"local: just tests::local {category} | "
63
f
"container: just tests::devcontainer {category}\n"
64
)
65
for
test_name, description
in
tests:
66
print(f
" {test_name.ljust(NAME_COLUMN_WIDTH)} {description}"
)
67
print()
68
69
70
if
__name__ ==
"__main__"
:
71
main
()
main
void main(void)
The application entry point Reset_Handler hands control to.
Definition
main.c:298
scripts
dev
list_tests.py
Generated by
1.16.1