[rtems-central commit] rtemsspec: Fix augment_with_test_links()

Sebastian Huber sebh at rtems.org
Wed Jul 27 15:33:42 UTC 2022


Module:    rtems-central
Branch:    master
Commit:    edc79fa9a0347959cd2afafc0c30de70e03002a6
Changeset: http://git.rtems.org/rtems-central/commit/?id=edc79fa9a0347959cd2afafc0c30de70e03002a6

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jul 27 17:40:37 2022 +0200

rtemsspec: Fix augment_with_test_links()

Add also parent links.

---

 rtemsspec/items.py            | 6 +++++-
 rtemsspec/rtems.py            | 1 +
 rtemsspec/tests/test_rtems.py | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index d9cee00b..2c0e25fa 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -382,8 +382,12 @@ class Item:
         for link in self.links_to_parents():
             link.item.add_link_to_child(Link.create(link, self))
 
+    def add_link_to_parent(self, link: Link):
+        """ Adds the link as a parent item link to this item. """
+        self._links_to_parents.append(link)
+
     def add_link_to_child(self, link: Link):
-        """ Adds a link to a child item of this items. """
+        """ Adds the link as a child item link to this item. """
         self._links_to_children.append(link)
 
     def is_enabled(self, enabled: List[str]):
diff --git a/rtemsspec/rtems.py b/rtemsspec/rtems.py
index b2bcfd12..97e9da82 100644
--- a/rtemsspec/rtems.py
+++ b/rtemsspec/rtems.py
@@ -43,6 +43,7 @@ def is_pre_qualified(item: Item) -> bool:
 def _add_link(item_cache: ItemCache, child: Item, link: Link) -> None:
     parent = item_cache[child.to_abs_uid(link["uid"])]
     parent.add_link_to_child(Link(child, link))
+    child.add_link_to_parent(Link(parent, link))
 
 
 def augment_with_test_links(item_cache: ItemCache) -> None:
diff --git a/rtemsspec/tests/test_rtems.py b/rtemsspec/tests/test_rtems.py
index f412a543..25894344 100644
--- a/rtemsspec/tests/test_rtems.py
+++ b/rtemsspec/tests/test_rtems.py
@@ -60,3 +60,4 @@ def test_augment_with_test_links():
     test_case.data["_type"] = "test-case"
     augment_with_test_links(item_cache)
     assert item.child("validation") == test_case
+    assert test_case.parent("validation") == item



More information about the vc mailing list