[rtems-central commit] items: Add "initialize-links" option to ItemCache

Sebastian Huber sebh at rtems.org
Tue May 9 13:45:26 UTC 2023


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May  5 14:41:19 2023 +0200

items: Add "initialize-links" option to ItemCache

---

 rtemsspec/items.py                      | 5 +++--
 rtemsspec/tests/test_items_itemcache.py | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 1adbcdc7..1bc29dec 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -755,8 +755,9 @@ class ItemCache:
         self._load_items(config)
         if post_process_load:
             post_process_load(self._items)
-        self._init_parents()
-        self._init_children()
+        if config.get("initialize-links", True):
+            self._init_parents()
+            self._init_children()
         spec_root = config["spec-type-root-uid"]
         if spec_root:
             self._root_type = _gather_spec_refinements(self[spec_root])
diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py
index ff75db12..6cb35e3e 100644
--- a/rtemsspec/tests/test_items_itemcache.py
+++ b/rtemsspec/tests/test_items_itemcache.py
@@ -96,6 +96,9 @@ v: x""")
 def test_load_link_error(tmpdir):
     config = create_item_cache_config_and_copy_spec(tmpdir,
                                                     "spec-item-cache-2")
+    config["initialize-links"] = False
+    ItemCache(config)
+    config["initialize-links"] = True
     with pytest.raises(
             KeyError,
             match=r"^\"item '/a' links to non-existing item 'nix'\"$"):



More information about the vc mailing list