summaryrefslogtreecommitdiffstats
path: root/rtemsspec
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-14 07:19:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-19 11:29:34 +0200
commit09213e2f216bd0628be14b77cd736dbd6b34c61a (patch)
treef4e0cb2da41513865cd1f503bf8cd18e16831702 /rtemsspec
parentvalidation: Update due to test API changes (diff)
downloadrtems-central-09213e2f216bd0628be14b77cd736dbd6b34c61a.tar.bz2
validation: Use dictionary to gather items
Diffstat (limited to 'rtemsspec')
-rw-r--r--rtemsspec/validation.py52
1 files changed, 36 insertions, 16 deletions
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 53139029..e37d5a56 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -737,21 +737,40 @@ def _get_source_file(filename: str,
return source_files.setdefault(filename, _SourceFile(filename))
-def _gather_items(item: Item, source_files: Dict[str, _SourceFile],
- test_programs: List[_TestProgram]) -> None:
- if item["type"] == "test-suite":
- src = _get_source_file(item["target"], source_files)
- src.add_test_suite(item)
- elif item["type"] == "test-case":
- src = _get_source_file(item["target"], source_files)
- src.add_test_case(item)
- elif item["type"] == "requirement" and item[
- "requirement-type"] == "functional" and item[
- "functional-type"] == "action":
- src = _get_source_file(item["test-target"], source_files)
- src.add_test_directive(item)
- elif item["type"] == "build" and item["build-type"] == "test-program":
- test_programs.append(_TestProgram(item))
+def _gather_action(item: Item, source_files: Dict[str, _SourceFile],
+ _test_programs: List[_TestProgram]) -> None:
+ src = _get_source_file(item["test-target"], source_files)
+ src.add_test_directive(item)
+
+
+def _gather_test_case(item: Item, source_files: Dict[str, _SourceFile],
+ _test_programs: List[_TestProgram]) -> None:
+ src = _get_source_file(item["target"], source_files)
+ src.add_test_case(item)
+
+
+def _gather_test_program(item: Item, _source_files: Dict[str, _SourceFile],
+ test_programs: List[_TestProgram]) -> None:
+ test_programs.append(_TestProgram(item))
+
+
+def _gather_test_suite(item: Item, source_files: Dict[str, _SourceFile],
+ _test_programs: List[_TestProgram]) -> None:
+ src = _get_source_file(item["target"], source_files)
+ src.add_test_suite(item)
+
+
+def _gather_default(_item: Item, _source_files: Dict[str, _SourceFile],
+ _test_programs: List[_TestProgram]) -> None:
+ pass
+
+
+_GATHER = {
+ "requirement/functional/action": _gather_action,
+ "test-case": _gather_test_case,
+ "build/test-program": _gather_test_program,
+ "test-suite": _gather_test_suite,
+}
def generate(config: dict, item_cache: ItemCache) -> None:
@@ -766,7 +785,8 @@ def generate(config: dict, item_cache: ItemCache) -> None:
source_files = {} # type: Dict[str, _SourceFile]
test_programs = [] # type: List[_TestProgram]
for item in item_cache.all.values():
- _gather_items(item, source_files, test_programs)
+ _GATHER.get(item.type, _gather_default)(item, source_files,
+ test_programs)
test_case_to_suites = {} # type: Dict[str, List[_TestItem]]
for test_program in test_programs: