[rtems-central commit] content: Fix code coverage issues
Sebastian Huber
sebh at rtems.org
Fri Sep 18 11:31:55 UTC 2020
Module: rtems-central
Branch: master
Commit: 6f82df1c49d5238556a8a4ceffc50092b99c0b04
Changeset: http://git.rtems.org/rtems-central/commit/?id=6f82df1c49d5238556a8a4ceffc50092b99c0b04
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jul 31 17:42:03 2020 +0200
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 cfef89c..3a25b7e 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 5367826..15564d2 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():
More information about the vc
mailing list