summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-05 14:41:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-08 21:58:56 +0200
commitf0cf2f28a67e8c1c53244a0ad1b12cb37aa48f73 (patch)
treed4d851bb504ffb07d7b683841909b4efa478bb13
parentspec: Use ${.:/step} (diff)
downloadrtems-central-f0cf2f28a67e8c1c53244a0ad1b12cb37aa48f73.tar.bz2
items: Remove ${spec} substitution
-rw-r--r--rtemsspec/items.py23
-rw-r--r--rtemsspec/tests/spec-validation/tc.yml2
-rw-r--r--rtemsspec/tests/test_items_itemcache.py2
-rw-r--r--rtemsspec/tests/test_validation.py2
-rw-r--r--rtemsspec/validation.py6
5 files changed, 17 insertions, 18 deletions
diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 9beb180d..00960bbf 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -475,7 +475,7 @@ def create_unique_link(child: Item, parent: Item, data: Any) -> None:
class ItemTemplate(string.Template):
""" String template for item mapper identifiers. """
- idpattern = "[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._/-]+)?(:[^${}]*)?"
+ idpattern = "[a-zA-Z0-9._/-]+:[\\[\\]a-zA-Z0-9._/-]+(:[^${}]*)?"
class _ItemMapperContext(dict):
@@ -601,20 +601,15 @@ class ItemMapper:
path, and attribute value.
"""
colon = identifier.find(":")
- if colon >= 0:
- uid = identifier[:colon]
- more = identifier[colon + 1:]
- colon = more.find(":")
- if colon < 0:
- key_path = more
- args = None
- else:
- key_path = more[:colon]
- args = more[colon + 1:]
- else:
- uid = identifier
- key_path = "/_uid"
+ uid = identifier[:colon]
+ more = identifier[colon + 1:]
+ colon = more.find(":")
+ if colon < 0:
+ key_path = more
args = None
+ else:
+ key_path = more[:colon]
+ args = more[colon + 1:]
if item is None:
item = self._item
if uid == ".":
diff --git a/rtemsspec/tests/spec-validation/tc.yml b/rtemsspec/tests/spec-validation/tc.yml
index c72b7c84..4bcd64b1 100644
--- a/rtemsspec/tests/spec-validation/tc.yml
+++ b/rtemsspec/tests/spec-validation/tc.yml
@@ -39,7 +39,7 @@ test-actions:
test-brief: Test case brief description.
test-context: []
test-context-support: null
-test-description: Test case description.
+test-description: Test case description. Is contained in ${ts:/spec}.
test-header: null
test-includes:
- a.h
diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py
index ba1ed859..261fa2f7 100644
--- a/rtemsspec/tests/test_items_itemcache.py
+++ b/rtemsspec/tests/test_items_itemcache.py
@@ -148,7 +148,6 @@ def test_item_mapper(tmpdir):
with mapper.prefix("x"):
with mapper.prefix("y"):
assert mapper[".:."] == "z"
- assert mapper["."] == "/p"
match = r"cannot get value for '/v' of spec:/proxy specified by 'proxy:/v"
with pytest.raises(ValueError, match=match):
mapper["proxy:/v"]
@@ -157,7 +156,6 @@ def test_item_mapper(tmpdir):
assert not item_cache["/r"].resolved_proxy
assert mapper["proxy2:/v"] == "s"
assert item_cache["/r"].child("xyz").uid == "/s"
- assert mapper["d/c"] == "/d/c"
assert mapper["d/c:v"] == "c"
assert mapper["d/c:a/b"] == "e"
mapper.add_get_value("other:/a/x-to-b", get_x_to_b_value)
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 698d2dfe..8a3f9f92 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -759,7 +759,7 @@ T_TEST_CASE_FIXTURE( Directive, &Directive_Fixture )
*
* @brief Test case brief description.
*
- * Test case description.
+ * Test case description. Is contained in spec:/ts.
*
* This test case performs the following actions:
*
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 484cc3d4..48ed2a9c 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -42,6 +42,10 @@ from rtemsspec.transitionmap import TransitionMap
_CaseToSuite = Dict[str, List["_TestItem"]]
+def _get_spec(ctx: ItemGetValueContext) -> Any:
+ return ctx.item.spec
+
+
def _get_test_context_instance(ctx: ItemGetValueContext) -> Any:
return f"{ctx.item.ident}_Instance"
@@ -94,6 +98,8 @@ class _Mapper(ItemMapper):
_get_test_context_type)
self.add_get_value("test-case:/test-run", _get_test_run)
self.add_get_value("test-suite:/test-suite-name", _get_test_suite_name)
+ for type_name in item.cache.items_by_type.keys():
+ self.add_get_value(f"{type_name}:/spec", _get_spec)
@property
def steps(self):