1313# software without disclosing the source code of your own applications. To purchase 
1414# a commercial license, send an email to license@arduino.cc. 
1515import  os 
16- import  hashlib 
17- import  tempfile 
1816import  shutil 
17+ import  json 
1918from  pathlib  import  Path 
2019
2120import  pytest 
@@ -250,7 +249,10 @@ def test_upload_sketch_with_pde_extension(run_command, data_dir, detected_boards
250249        assert  run_command (f"core install { core }  )
251250
252251        # Compile sketch first 
253-         assert  run_command (f"compile --clean -b { board .fqbn } { sketch_path }  )
252+         res  =  run_command (f"compile --clean -b { board .fqbn } { sketch_path }  )
253+         assert  res .ok 
254+         data  =  json .loads (res .stdout )
255+         build_dir  =  Path (data ["builder_result" ]["build_path" ])
254256
255257        # Upload from sketch folder 
256258        wait_for_board ()
@@ -260,9 +262,6 @@ def test_upload_sketch_with_pde_extension(run_command, data_dir, detected_boards
260262        wait_for_board ()
261263        assert  run_command (f"upload -b { board .fqbn } { board .address } { sketch_file }  )
262264
263-         # Upload from build folder 
264-         sketch_path_md5  =  hashlib .md5 (bytes (sketch_path )).hexdigest ().upper ()
265-         build_dir  =  Path (tempfile .gettempdir (), f"arduino-sketch-{ sketch_path_md5 }  )
266265        wait_for_board ()
267266        res  =  run_command (f"upload -b { board .fqbn } { board .address } { build_dir }  )
268267        assert  (
@@ -301,14 +300,14 @@ def test_upload_with_input_dir_containing_multiple_binaries(run_command, data_di
301300        assert  run_command (f"core install { core }  )
302301
303302        # Compile both sketches and copy binaries in the same directory same build directory 
304-         assert   run_command (f"compile --clean -b { board .fqbn } { sketch_one_path }  )
305-         assert  run_command ( f"compile --clean -b  { board . fqbn }   { sketch_two_path } " ) 
306- 
307-         sketch_path_md5  =  hashlib . md5 ( bytes ( sketch_one_path )). hexdigest (). upper ( )
308-         build_dir_one  =  Path ( tempfile . gettempdir (),  f"arduino-sketch- { sketch_path_md5 } 
309- 
310-         sketch_path_md5  =  hashlib . md5 ( bytes ( sketch_two_path )). hexdigest (). upper ( )
311-         build_dir_two  =  Path (tempfile . gettempdir (),  f"arduino-sketch- { sketch_path_md5 } " 
303+         res   =   run_command (f"compile --clean -b { board .fqbn } { sketch_one_path }  --format json " )
304+         assert  res . ok 
305+          data   =   json . loads ( res . stdout ) 
306+         build_dir_one  =  Path ( data [ "builder_result" ][ "build_path" ] )
307+         res  =  run_command ( f"compile --clean -b  { board . fqbn }   { sketch_two_path }  --format json "
308+          assert   res . ok 
309+         data  =  json . loads ( res . stdout )
310+         build_dir_two  =  Path (data [ "builder_result" ][ "build_path" ] )
312311
313312        # Copy binaries to same folder 
314313        binaries_dir  =  Path (data_dir , "build" , "BuiltBinaries" )
0 commit comments