|
3 | 3 | import os
|
4 | 4 | from string import printable
|
5 | 5 | from copy import deepcopy
|
| 6 | +from mock import MagicMock |
6 | 7 | from hypothesis import given
|
7 | 8 | from hypothesis.strategies import text, lists, fixed_dictionaries
|
8 | 9 |
|
9 | 10 | ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
|
10 | 11 | ".."))
|
11 | 12 | sys.path.insert(0, ROOT)
|
12 | 13 |
|
13 |
| -from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES |
| 14 | +from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\ |
| 15 | + Resources |
14 | 16 | from tools.targets import TARGET_MAP
|
15 | 17 |
|
16 | 18 | def test_instantiation():
|
@@ -96,3 +98,27 @@ def test_toolchain_profile_asm(profile, source_file):
|
96 | 98 | "Toolchain %s did not propigate arg %s" % (toolchain.name,
|
97 | 99 | parameter)
|
98 | 100 |
|
| 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