3
3
import os
4
4
from string import printable
5
5
from copy import deepcopy
6
- from mock import MagicMock
6
+ from mock import MagicMock , patch
7
7
from hypothesis import given
8
8
from hypothesis .strategies import text , lists , fixed_dictionaries
9
9
@@ -37,16 +37,17 @@ def test_toolchain_profile_c(profile, source_file):
37
37
filename = deepcopy (source_file )
38
38
filename [- 1 ] += ".c"
39
39
to_compile = os .path .join (* filename )
40
- for _ , tc_class in TOOLCHAIN_CLASSES .items ():
41
- toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
42
- toolchain .inc_md5 = ""
43
- toolchain .build_dir = ""
44
- compile_command = toolchain .compile_command (to_compile ,
45
- to_compile + ".o" , [])
46
- for parameter in profile ['c' ] + profile ['common' ]:
47
- assert any (parameter in cmd for cmd in compile_command ), \
48
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
49
- parameter )
40
+ with patch ('os.mkdir' ) as _mkdir :
41
+ for _ , tc_class in TOOLCHAIN_CLASSES .items ():
42
+ toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
43
+ toolchain .inc_md5 = ""
44
+ toolchain .build_dir = ""
45
+ compile_command = toolchain .compile_command (to_compile ,
46
+ to_compile + ".o" , [])
47
+ for parameter in profile ['c' ] + profile ['common' ]:
48
+ assert any (parameter in cmd for cmd in compile_command ), \
49
+ "Toolchain %s did not propigate arg %s" % (toolchain .name ,
50
+ parameter )
50
51
51
52
@given (fixed_dictionaries ({
52
53
'common' : lists (text ()),
@@ -61,16 +62,17 @@ def test_toolchain_profile_cpp(profile, source_file):
61
62
filename = deepcopy (source_file )
62
63
filename [- 1 ] += ".cpp"
63
64
to_compile = os .path .join (* filename )
64
- for _ , tc_class in TOOLCHAIN_CLASSES .items ():
65
- toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
66
- toolchain .inc_md5 = ""
67
- toolchain .build_dir = ""
68
- compile_command = toolchain .compile_command (to_compile ,
69
- to_compile + ".o" , [])
70
- for parameter in profile ['cxx' ] + profile ['common' ]:
71
- assert any (parameter in cmd for cmd in compile_command ), \
72
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
73
- parameter )
65
+ with patch ('os.mkdir' ) as _mkdir :
66
+ for _ , tc_class in TOOLCHAIN_CLASSES .items ():
67
+ toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
68
+ toolchain .inc_md5 = ""
69
+ toolchain .build_dir = ""
70
+ compile_command = toolchain .compile_command (to_compile ,
71
+ to_compile + ".o" , [])
72
+ for parameter in profile ['cxx' ] + profile ['common' ]:
73
+ assert any (parameter in cmd for cmd in compile_command ), \
74
+ "Toolchain %s did not propigate arg %s" % (toolchain .name ,
75
+ parameter )
74
76
75
77
@given (fixed_dictionaries ({
76
78
'common' : lists (text ()),
@@ -85,18 +87,19 @@ def test_toolchain_profile_asm(profile, source_file):
85
87
filename = deepcopy (source_file )
86
88
filename [- 1 ] += ".s"
87
89
to_compile = os .path .join (* filename )
88
- for _ , tc_class in TOOLCHAIN_CLASSES .items ():
89
- toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
90
- toolchain .inc_md5 = ""
91
- toolchain .build_dir = ""
92
- compile_command = toolchain .compile_command (to_compile ,
93
- to_compile + ".o" , [])
94
- if not compile_command :
95
- assert compile_command , to_compile
96
- for parameter in profile ['asm' ]:
97
- assert any (parameter in cmd for cmd in compile_command ), \
98
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
99
- parameter )
90
+ with patch ('os.mkdir' ) as _mkdir :
91
+ for _ , tc_class in TOOLCHAIN_CLASSES .items ():
92
+ toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
93
+ toolchain .inc_md5 = ""
94
+ toolchain .build_dir = ""
95
+ compile_command = toolchain .compile_command (to_compile ,
96
+ to_compile + ".o" , [])
97
+ if not compile_command :
98
+ assert compile_command , to_compile
99
+ for parameter in profile ['asm' ]:
100
+ assert any (parameter in cmd for cmd in compile_command ), \
101
+ "Toolchain %s did not propigate arg %s" % (toolchain .name ,
102
+ parameter )
100
103
101
104
for name , Class in TOOLCHAIN_CLASSES .items ():
102
105
CLS = Class (TARGET_MAP ["K64F" ])
0 commit comments