Skip to content

Commit 5eed4f2

Browse files
committed
Add a test of find duplicates
1 parent 5f8fbac commit 5eed4f2

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tools/test/toolchains/api.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import os
44
from string import printable
55
from copy import deepcopy
6+
from mock import MagicMock
67
from hypothesis import given
78
from hypothesis.strategies import text, lists, fixed_dictionaries
89

910
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
1011
".."))
1112
sys.path.insert(0, ROOT)
1213

13-
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES
14+
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
15+
Resources
1416
from tools.targets import TARGET_MAP
1517

1618
def test_instantiation():
@@ -96,3 +98,27 @@ def test_toolchain_profile_asm(profile, source_file):
9698
"Toolchain %s did not propigate arg %s" % (toolchain.name,
9799
parameter)
98100

101+
for name, Class in TOOLCHAIN_CLASSES.items():
102+
CLS = Class(TARGET_MAP["K64F"])
103+
assert name == CLS.name or name == LEGACY_TOOLCHAIN_NAMES[CLS.name]
104+
105+
106+
@given(lists(text(alphabet=ALPHABET, min_size=1), min_size=1))
107+
def test_detect_duplicates(filenames):
108+
c_sources = [os.path.join(name, "dupe.c") for name in filenames]
109+
s_sources = [os.path.join(name, "dupe.s") for name in filenames]
110+
cpp_sources = [os.path.join(name, "dupe.cpp") for name in filenames]
111+
with MagicMock() as notify:
112+
toolchain = TOOLCHAIN_CLASSES["ARM"](TARGET_MAP["K64F"], notify=notify)
113+
res = Resources()
114+
res.c_sources = c_sources
115+
res.s_sources = s_sources
116+
res.cpp_sources = cpp_sources
117+
assert res.detect_duplicates(toolchain) == 1,\
118+
"Not Enough duplicates found"
119+
120+
_, (notification, _), _ = notify.mock_calls[1]
121+
assert "dupe.o" in notification["message"]
122+
assert "dupe.s" in notification["message"]
123+
assert "dupe.c" in notification["message"]
124+
assert "dupe.cpp" in notification["message"]

0 commit comments

Comments
 (0)