summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-07-31 17:42:03 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-18 13:27:36 +0200
commit6f82df1c49d5238556a8a4ceffc50092b99c0b04 (patch)
tree6eb72a132e654d52f9c87093467e4d3143e82a35
parentspecdoc: Add pattern to ignore types (diff)
downloadrtems-central-6f82df1c49d5238556a8a4ceffc50092b99c0b04.tar.bz2
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.
-rw-r--r--rtemsspec/content.py2
-rw-r--r--rtemsspec/tests/test_content_c.py8
2 files changed, 9 insertions, 1 deletions
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
@@ -159,6 +159,14 @@ def test_add_includes():
#include <a>
#endif
"""
+ content = CContent()
+ content.add_includes([CInclude("a", "X"), CInclude("b")])
+ assert str(content) == """#include <b>
+
+#if X
+ #include <a>
+#endif
+"""
def test_comment_block():