Test and correct GCC version check

pull/7247/head
Jimmy Brisson 2018-06-26 09:25:33 -05:00
parent 8c17a31c42
commit c273de6545
2 changed files with 33 additions and 2 deletions

View File

@ -60,6 +60,37 @@ def test_iar_version_check(_run_cmd):
assert len(notifier.messages) == 2
@patch('tools.toolchains.gcc.run_cmd')
def test_gcc_version_check(_run_cmd):
_run_cmd.return_value = ("""
arm-none-eabi-gcc (Arch Repository) 6.4.4
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
""", "", 0)
notifier = MockNotifier()
toolchain = TOOLCHAIN_CLASSES["GCC_ARM"](
TARGET_MAP["K64F"], notify=notifier)
toolchain.version_check()
assert notifier.messages == []
_run_cmd.return_value = ("""
arm-none-eabi-gcc (Arch Repository) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
""", "", 0)
toolchain.version_check()
assert len(notifier.messages) == 1
_run_cmd.return_value = ("""
arm-none-eabi-gcc (Arch Repository)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
""", "", 0)
toolchain.version_check()
assert len(notifier.messages) == 2
@given(fixed_dictionaries({
'common': lists(text()),
'c': lists(text()),

View File

@ -31,7 +31,7 @@ class GCC(mbedToolchain):
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
GCC_RANGE = (LooseVersion("6.0.0"), LooseVersion("7.0.0"))
GCC_VERSION_RE = re.compile("[0-9]*\.[0-9]*\.[0-9]*")
GCC_VERSION_RE = re.compile("\d+\.\d+\.\d+")
def __init__(self, target, notify=None, macros=None, build_profile=None,
build_dir=None):
@ -122,7 +122,7 @@ class GCC(mbedToolchain):
msg = ("Compiler version mismatch: Have {}; "
"expected version >= {} and < {}"
.format(found_version, min_ver, max_ver))
elif not match or len(match.groups()) != 1:
elif not match:
msg = ("Compiler version mismatch: Could not detect version; "
"expected version >= {} and < {}"
.format(min_ver, max_ver))