mirror of https://github.com/ARMmbed/mbed-os.git
Add unit test for gcc path specifications
parent
c3d0ca30c3
commit
e949b857a0
|
@ -4,15 +4,15 @@ import os
|
||||||
from string import printable
|
from string import printable
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from mock import MagicMock, patch
|
from mock import MagicMock, patch
|
||||||
from hypothesis import given
|
from hypothesis import given, settings
|
||||||
from hypothesis.strategies import text, lists, fixed_dictionaries
|
from hypothesis.strategies import text, lists, fixed_dictionaries, booleans
|
||||||
|
|
||||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
|
||||||
".."))
|
".."))
|
||||||
sys.path.insert(0, ROOT)
|
sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
|
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
|
||||||
Resources
|
Resources, TOOLCHAIN_PATHS
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
|
|
||||||
def test_instantiation():
|
def test_instantiation():
|
||||||
|
@ -125,3 +125,21 @@ def test_detect_duplicates(filenames):
|
||||||
assert "dupe.s" in notification["message"]
|
assert "dupe.s" in notification["message"]
|
||||||
assert "dupe.c" in notification["message"]
|
assert "dupe.c" in notification["message"]
|
||||||
assert "dupe.cpp" in notification["message"]
|
assert "dupe.cpp" in notification["message"]
|
||||||
|
|
||||||
|
@given(text(alphabet=ALPHABET + ["/"], min_size=1))
|
||||||
|
@given(booleans())
|
||||||
|
@given(booleans())
|
||||||
|
@settings(max_examples=20)
|
||||||
|
def test_path_specified_gcc(gcc_loc, exists_at_loc, exists_in_path):
|
||||||
|
with patch('tools.toolchains.gcc.exists') as _exists:
|
||||||
|
with patch('tools.toolchains.gcc.find_executable') as _find:
|
||||||
|
_exists.return_value = exists_at_loc
|
||||||
|
_find.return_value = exists_in_path
|
||||||
|
TOOLCHAIN_PATHS['GCC_ARM'] = gcc_loc
|
||||||
|
toolchain_class = TOOLCHAIN_CLASSES["GCC_ARM"]
|
||||||
|
found_p = toolchain_class.check_executable()
|
||||||
|
assert found_p == (exists_at_loc or exists_in_path)
|
||||||
|
if exists_at_loc:
|
||||||
|
assert TOOLCHAIN_PATHS['GCC_ARM'] == gcc_loc
|
||||||
|
elif exists_in_path:
|
||||||
|
assert TOOLCHAIN_PATHS['GCC_ARM'] == ''
|
||||||
|
|
Loading…
Reference in New Issue