From 6d70c4df1678c8761884d89198781aa74f6c1974 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 5 May 2023 14:41:19 +0200 Subject: 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'\"$"): -- cgit v1.2.3