From 6f82df1c49d5238556a8a4ceffc50092b99c0b04 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 31 Jul 2020 17:42:03 +0200 Subject: content: Fix code coverage issues The problem was that the conversion of a list to a set destroys the order. The order of set elements is not deterministic. Use an order preserving way remove duplicates. --- rtemsspec/content.py | 2 +- rtemsspec/tests/test_content_c.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rtemsspec/content.py b/rtemsspec/content.py index cfef89c6..3a25b7ec 100644 --- a/rtemsspec/content.py +++ b/rtemsspec/content.py @@ -477,7 +477,7 @@ def _split_includes( includes: List[CInclude]) -> Tuple[Set[str], Dict[str, Set[str]]]: includes_unconditional = set() # type: Set[str] includes_enabled_by = {} # type: Dict[str, Set[str]] - for inc in set(includes): + for inc in list(dict.fromkeys(includes)): if inc.enabled_by and inc.enabled_by != "1": try: includes_unconditional.remove(inc.path) diff --git a/rtemsspec/tests/test_content_c.py b/rtemsspec/tests/test_content_c.py index 5367826a..15564d24 100644 --- a/rtemsspec/tests/test_content_c.py +++ b/rtemsspec/tests/test_content_c.py @@ -158,6 +158,14 @@ def test_add_includes(): #if X && Y #include #endif +""" + content = CContent() + content.add_includes([CInclude("a", "X"), CInclude("b")]) + assert str(content) == """#include + +#if X + #include +#endif """ -- cgit v1.2.3