@@ -200,53 +200,83 @@ def test_build_folder_removed_when_clean_flag_passed(
200200 self .assertFalse (program .files .cmake_build_dir .exists ())
201201
202202 @mock .patch ("mbed_tools.cli.build.flash_binary" )
203+ @mock .patch ("mbed_tools.cli.build.is_image_hex" )
203204 @mock .patch ("mbed_tools.cli.build.find_all_connected_devices" )
204- def test_build_flash_option (
205- self , mock_find_devices , flash_binary , generate_config , mbed_program , build_project , generate_build_system
205+ def test_build_flash_option_bin_target (
206+ self ,
207+ mock_find_devices ,
208+ is_image_hex ,
209+ flash_binary ,
210+ generate_config ,
211+ mbed_program ,
212+ build_project ,
213+ generate_build_system ,
206214 ):
207215 mock_find_devices .return_value = [mock .MagicMock ()]
216+ is_image_hex .return_value = False
208217 runner = CliRunner ()
209218 runner .invoke (build , ["--flash" , * DEFAULT_BUILD_ARGS ])
210- flash_binary .assert_called_once ()
219+ call_args = flash_binary .call_args
220+ args , kwargs = call_args
221+ flash_binary .assert_called_once_with (args [0 ], args [1 ], args [2 ], args [3 ], False )
211222
212223 @mock .patch ("mbed_tools.cli.build.flash_binary" )
224+ @mock .patch ("mbed_tools.cli.build.is_image_hex" )
213225 @mock .patch ("mbed_tools.cli.build.find_all_connected_devices" )
214- def test_build_flash_and_hex_file_options (
215- self , mock_find_devices , flash_binary , generate_config , mbed_program , build_project , generate_build_system
226+ def test_build_flash_options_hex_target (
227+ self ,
228+ mock_find_devices ,
229+ is_image_hex ,
230+ flash_binary ,
231+ generate_config ,
232+ mbed_program ,
233+ build_project ,
234+ generate_build_system ,
216235 ):
217236 mock_find_devices .return_value = [mock .MagicMock ()]
237+ is_image_hex .return_value = True
218238 runner = CliRunner ()
219- runner .invoke (build , ["--flash" , "--hex-file" , * DEFAULT_BUILD_ARGS ])
239+ runner .invoke (build , ["--flash" , * DEFAULT_BUILD_ARGS ])
220240 call_args = flash_binary .call_args
221241 args , kwargs = call_args
222242 flash_binary .assert_called_once_with (args [0 ], args [1 ], args [2 ], args [3 ], True )
223243
224244 @mock .patch ("mbed_tools.cli.build.flash_binary" )
245+ @mock .patch ("mbed_tools.cli.build.is_image_hex" )
225246 @mock .patch ("mbed_tools.cli.build.find_all_connected_devices" )
226247 def test_build_flash_both_two_devices (
227- self , mock_find_devices , flash_binary , generate_config , mbed_program , build_project , generate_build_system
248+ self ,
249+ mock_find_devices ,
250+ is_image_hex ,
251+ flash_binary ,
252+ generate_config ,
253+ mbed_program ,
254+ build_project ,
255+ generate_build_system ,
228256 ):
229257 mock_find_devices .return_value = [mock .MagicMock (), mock .MagicMock ()]
230258 runner = CliRunner ()
231259 runner .invoke (build , ["--flash" , * DEFAULT_BUILD_ARGS ])
232260 self .assertEqual (flash_binary .call_count , 2 )
233261
234262 @mock .patch ("mbed_tools.cli.build.flash_binary" )
263+ @mock .patch ("mbed_tools.cli.build.is_image_hex" )
235264 @mock .patch ("mbed_tools.cli.build.find_connected_device" )
236265 def test_build_flash_only_identifier_device (
237- self , mock_find_device , flash_binary , generate_config , mbed_program , build_project , generate_build_system
266+ self ,
267+ mock_find_device ,
268+ is_image_hex ,
269+ flash_binary ,
270+ generate_config ,
271+ mbed_program ,
272+ build_project ,
273+ generate_build_system ,
238274 ):
239275 mock_find_device .return_value = mock .MagicMock ()
240276 runner = CliRunner ()
241277 runner .invoke (build , ["--flash" , "-m" , "K64F[1]" , "-t" , "GCC_ARM" ])
242278 self .assertEqual (flash_binary .call_count , 1 )
243279
244- def test_build_only_hex_file_option (self , generate_config , mbed_program , build_project , generate_build_system ):
245- runner = CliRunner ()
246- result = runner .invoke (build , ["--hex-file" , * DEFAULT_BUILD_ARGS ])
247-
248- self .assertRegex (result .output , "-f/--flash" )
249-
250280 @mock .patch ("mbed_tools.cli.build.terminal" )
251281 @mock .patch ("mbed_tools.cli.build.find_connected_device" )
252282 def test_sterm_is_started_when_flag_passed (
0 commit comments