Correct resources usage in tests

pull/7183/head
Jimmy Brisson 2018-06-11 13:27:05 -05:00
parent a57942a813
commit 6ca218544d
2 changed files with 13 additions and 12 deletions

View File

@ -229,25 +229,22 @@ class Resources(object):
dupe_headers[headername] |= set([headername])
return dupe_dict, dupe_headers
def detect_duplicates(self, toolchain):
def detect_duplicates(self):
"""Detect all potential ambiguities in filenames and report them with
a toolchain notification
Positional Arguments:
toolchain - used for notifications
"""
count = 0
dupe_dict, dupe_headers = self._collect_duplicates(dict(), dict())
for objname, filenames in dupe_dict.items():
if len(filenames) > 1:
count+=1
toolchain.tool_error(
self.notify.tool_error(
"Object file %s.o is not unique! It could be made from: %s"\
% (objname, " ".join(filenames)))
for headername, locations in dupe_headers.items():
if len(locations) > 1:
count+=1
toolchain.tool_error(
self.notify.tool_error(
"Header file %s is not unique! It could be: %s" %\
(headername, " ".join(locations)))
return count

View File

@ -11,9 +11,13 @@ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
".."))
sys.path.insert(0, ROOT)
from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
Resources, TOOLCHAIN_PATHS, mbedToolchain
from tools.targets import TARGET_MAP
from tools.toolchains import (
TOOLCHAIN_CLASSES,
TOOLCHAIN_PATHS,
mbedToolchain,
)
from tools.resources import LEGACY_TOOLCHAIN_NAMES, Resources
from tools.targets import TARGET_MAP, set_targets_json_location
from tools.notifier.mock import MockNotifier
ALPHABET = [char for char in printable if char not in [u'.', u'/', u'\\']]
@ -111,6 +115,7 @@ def test_toolchain_profile_c(profile, source_file):
filename = deepcopy(source_file)
filename[-1] += ".c"
to_compile = os.path.join(*filename)
set_targets_json_location()
with patch('os.mkdir') as _mkdir:
for _, tc_class in TOOLCHAIN_CLASSES.items():
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
@ -241,12 +246,11 @@ def test_detect_duplicates(filenames):
s_sources = [os.path.join(name, "dupe.s") for name in filenames]
cpp_sources = [os.path.join(name, "dupe.cpp") for name in filenames]
notify = MockNotifier()
toolchain = TOOLCHAIN_CLASSES["ARM"](TARGET_MAP["K64F"], notify=notify)
res = Resources()
res = Resources(notify)
res.c_sources = c_sources
res.s_sources = s_sources
res.cpp_sources = cpp_sources
assert res.detect_duplicates(toolchain) == 1,\
assert res.detect_duplicates() == 1,\
"Not Enough duplicates found"
notification = notify.messages[0]