20
20
from mock import patch , MagicMock
21
21
from tools .build_api import prepare_toolchain , build_project , build_library
22
22
from tools .regions import merge_region_list
23
- from tools .resources import Resources
23
+ from tools .resources import Resources , FileType
24
24
from tools .toolchains import TOOLCHAINS
25
25
from tools .notifier .mock import MockNotifier
26
26
from tools .config import Region , Config , ConfigException
@@ -108,14 +108,7 @@ def test_compile_legacy_sources_always_complete_build(self, *_):
108
108
assert any ('percent' in msg and msg ['percent' ] == 100.0
109
109
for msg in notify .messages if msg )
110
110
111
- @patch ('tools.toolchains.arm.ARM_STD.parse_dependencies' ,
112
- return_value = ["foo" ])
113
- @patch ('tools.toolchains.mbedToolchain.need_update' ,
114
- side_effect = [i % 2 for i in range (3000 )])
115
- @patch ('os.mkdir' )
116
- @patch ('tools.toolchains.mbedToolchain.dump_build_profile' )
117
- @patch ('tools.utils.run_cmd' , return_value = (b'' , b'' , 0 ))
118
- def test_dirs_exclusion_from_build (self , * _ ):
111
+ def test_dirs_exclusion_from_file_to_compile (self , * _ ):
119
112
"""Test that dirs can be excluded from the build."""
120
113
notify = MockNotifier ()
121
114
toolchain = prepare_toolchain (self .src_paths , self .build_path , self .target ,
@@ -127,19 +120,24 @@ def test_dirs_exclusion_from_build(self, *_):
127
120
toolchain .RESPONSE_FILES = False
128
121
toolchain .config_processed = True
129
122
toolchain .config_file = "junk"
130
- exclude_dirs = ['platform/' ,'rtos /' , 'targets/' ]
123
+ exclude_dirs = ['platform/' ,'drivers /' , 'targets/' ]
131
124
132
- toolchain .compile_legacy_sources (
133
- res , inc_dirs = None , exclude_dirs = exclude_dirs
125
+ files_to_compile = (
126
+ res .get_file_refs (FileType .ASM_SRC ) +
127
+ res .get_file_refs (FileType .C_SRC ) +
128
+ res .get_file_refs (FileType .CPP_SRC )
129
+ )
130
+ compilation_queue = toolchain ._exclude_files_from_build (
131
+ files_to_compile , exclude_dirs
134
132
)
133
+
134
+ assert (len (compilation_queue ) < len (files_to_compile ))
135
135
assert all (
136
- exclude_dir not in msg
137
- for msg in notify .messages
138
- if msg
136
+ exclude_dir not in file_to_compile .path
137
+ for file_to_compile in compilation_queue
139
138
for exclude_dir in exclude_dirs
140
139
)
141
140
142
-
143
141
@patch ('tools.build_api.Config' )
144
142
def test_prepare_toolchain_app_config (self , mock_config_init ):
145
143
"""
0 commit comments