|
4 | 4 | from string import printable
|
5 | 5 | from copy import deepcopy
|
6 | 6 | from mock import MagicMock, patch
|
7 |
| -from hypothesis import given |
8 |
| -from hypothesis.strategies import text, lists, fixed_dictionaries |
| 7 | +from hypothesis import given, settings |
| 8 | +from hypothesis.strategies import text, lists, fixed_dictionaries, booleans |
9 | 9 |
|
10 | 10 | ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
|
11 | 11 | ".."))
|
12 | 12 | sys.path.insert(0, ROOT)
|
13 | 13 |
|
14 | 14 | from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
|
15 |
| - Resources |
| 15 | + Resources, TOOLCHAIN_PATHS |
16 | 16 | from tools.targets import TARGET_MAP
|
17 | 17 |
|
18 | 18 | def test_instantiation():
|
@@ -125,3 +125,21 @@ def test_detect_duplicates(filenames):
|
125 | 125 | assert "dupe.s" in notification["message"]
|
126 | 126 | assert "dupe.c" in notification["message"]
|
127 | 127 | assert "dupe.cpp" in notification["message"]
|
| 128 | + |
| 129 | +@given(text(alphabet=ALPHABET + ["/"], min_size=1)) |
| 130 | +@given(booleans()) |
| 131 | +@given(booleans()) |
| 132 | +@settings(max_examples=20) |
| 133 | +def test_path_specified_gcc(gcc_loc, exists_at_loc, exists_in_path): |
| 134 | + with patch('tools.toolchains.gcc.exists') as _exists: |
| 135 | + with patch('tools.toolchains.gcc.find_executable') as _find: |
| 136 | + _exists.return_value = exists_at_loc |
| 137 | + _find.return_value = exists_in_path |
| 138 | + TOOLCHAIN_PATHS['GCC_ARM'] = gcc_loc |
| 139 | + toolchain_class = TOOLCHAIN_CLASSES["GCC_ARM"] |
| 140 | + found_p = toolchain_class.check_executable() |
| 141 | + assert found_p == (exists_at_loc or exists_in_path) |
| 142 | + if exists_at_loc: |
| 143 | + assert TOOLCHAIN_PATHS['GCC_ARM'] == gcc_loc |
| 144 | + elif exists_in_path: |
| 145 | + assert TOOLCHAIN_PATHS['GCC_ARM'] == '' |
0 commit comments