Skip to content

Commit 4408c01

Browse files
committed
Add unit test for gcc path specifications
1 parent a5745ca commit 4408c01

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tools/test/toolchains/api.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
from string import printable
55
from copy import deepcopy
66
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
99

1010
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
1111
".."))
1212
sys.path.insert(0, ROOT)
1313

1414
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
15-
Resources
15+
Resources, TOOLCHAIN_PATHS
1616
from tools.targets import TARGET_MAP
1717

1818
def test_instantiation():
@@ -125,3 +125,21 @@ def test_detect_duplicates(filenames):
125125
assert "dupe.s" in notification["message"]
126126
assert "dupe.c" in notification["message"]
127127
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

Comments
 (0)