Merge pull request #2893 from theotherjimmy/toolchain-test-cleanup

[Tests] Prevent garbage generation from toolchain api test
pull/2898/head
Sam Grove 2016-10-03 17:22:00 -05:00 committed by GitHub
commit 79fbf94d9c
1 changed files with 36 additions and 33 deletions

View File

@ -3,7 +3,7 @@ import sys
import os import os
from string import printable from string import printable
from copy import deepcopy from copy import deepcopy
from mock import MagicMock from mock import MagicMock, patch
from hypothesis import given from hypothesis import given
from hypothesis.strategies import text, lists, fixed_dictionaries from hypothesis.strategies import text, lists, fixed_dictionaries
@ -37,16 +37,17 @@ def test_toolchain_profile_c(profile, source_file):
filename = deepcopy(source_file) filename = deepcopy(source_file)
filename[-1] += ".c" filename[-1] += ".c"
to_compile = os.path.join(*filename) to_compile = os.path.join(*filename)
for _, tc_class in TOOLCHAIN_CLASSES.items(): with patch('os.mkdir') as _mkdir:
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile) for _, tc_class in TOOLCHAIN_CLASSES.items():
toolchain.inc_md5 = "" toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile)
toolchain.build_dir = "" toolchain.inc_md5 = ""
compile_command = toolchain.compile_command(to_compile, toolchain.build_dir = ""
to_compile + ".o", []) compile_command = toolchain.compile_command(to_compile,
for parameter in profile['c'] + profile['common']: to_compile + ".o", [])
assert any(parameter in cmd for cmd in compile_command), \ for parameter in profile['c'] + profile['common']:
"Toolchain %s did not propigate arg %s" % (toolchain.name, assert any(parameter in cmd for cmd in compile_command), \
parameter) "Toolchain %s did not propigate arg %s" % (toolchain.name,
parameter)
@given(fixed_dictionaries({ @given(fixed_dictionaries({
'common': lists(text()), 'common': lists(text()),
@ -61,16 +62,17 @@ def test_toolchain_profile_cpp(profile, source_file):
filename = deepcopy(source_file) filename = deepcopy(source_file)
filename[-1] += ".cpp" filename[-1] += ".cpp"
to_compile = os.path.join(*filename) to_compile = os.path.join(*filename)
for _, tc_class in TOOLCHAIN_CLASSES.items(): with patch('os.mkdir') as _mkdir:
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile) for _, tc_class in TOOLCHAIN_CLASSES.items():
toolchain.inc_md5 = "" toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile)
toolchain.build_dir = "" toolchain.inc_md5 = ""
compile_command = toolchain.compile_command(to_compile, toolchain.build_dir = ""
to_compile + ".o", []) compile_command = toolchain.compile_command(to_compile,
for parameter in profile['cxx'] + profile['common']: to_compile + ".o", [])
assert any(parameter in cmd for cmd in compile_command), \ for parameter in profile['cxx'] + profile['common']:
"Toolchain %s did not propigate arg %s" % (toolchain.name, assert any(parameter in cmd for cmd in compile_command), \
parameter) "Toolchain %s did not propigate arg %s" % (toolchain.name,
parameter)
@given(fixed_dictionaries({ @given(fixed_dictionaries({
'common': lists(text()), 'common': lists(text()),
@ -85,18 +87,19 @@ def test_toolchain_profile_asm(profile, source_file):
filename = deepcopy(source_file) filename = deepcopy(source_file)
filename[-1] += ".s" filename[-1] += ".s"
to_compile = os.path.join(*filename) to_compile = os.path.join(*filename)
for _, tc_class in TOOLCHAIN_CLASSES.items(): with patch('os.mkdir') as _mkdir:
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile) for _, tc_class in TOOLCHAIN_CLASSES.items():
toolchain.inc_md5 = "" toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile)
toolchain.build_dir = "" toolchain.inc_md5 = ""
compile_command = toolchain.compile_command(to_compile, toolchain.build_dir = ""
to_compile + ".o", []) compile_command = toolchain.compile_command(to_compile,
if not compile_command: to_compile + ".o", [])
assert compile_command, to_compile if not compile_command:
for parameter in profile['asm']: assert compile_command, to_compile
assert any(parameter in cmd for cmd in compile_command), \ for parameter in profile['asm']:
"Toolchain %s did not propigate arg %s" % (toolchain.name, assert any(parameter in cmd for cmd in compile_command), \
parameter) "Toolchain %s did not propigate arg %s" % (toolchain.name,
parameter)
for name, Class in TOOLCHAIN_CLASSES.items(): for name, Class in TOOLCHAIN_CLASSES.items():
CLS = Class(TARGET_MAP["K64F"]) CLS = Class(TARGET_MAP["K64F"])