13
13
# software without disclosing the source code of your own applications. To purchase
14
14
# a commercial license, send an email to [email protected] .
15
15
import os
16
- import hashlib
17
- import tempfile
18
16
import shutil
17
+ import json
19
18
from pathlib import Path
20
19
21
20
import pytest
@@ -250,7 +249,10 @@ def test_upload_sketch_with_pde_extension(run_command, data_dir, detected_boards
250
249
assert run_command (f"core install { core } " )
251
250
252
251
# 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 } --format json" )
253
+ assert res .ok
254
+ data = json .loads (res .stdout )
255
+ build_dir = Path (data ["builder_result" ]["build_path" ])
254
256
255
257
# Upload from sketch folder
256
258
wait_for_board ()
@@ -260,9 +262,6 @@ def test_upload_sketch_with_pde_extension(run_command, data_dir, detected_boards
260
262
wait_for_board ()
261
263
assert run_command (f"upload -b { board .fqbn } -p { board .address } { sketch_file } " )
262
264
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 } " )
266
265
wait_for_board ()
267
266
res = run_command (f"upload -b { board .fqbn } -p { board .address } --input-dir { build_dir } " )
268
267
assert (
@@ -301,14 +300,14 @@ def test_upload_with_input_dir_containing_multiple_binaries(run_command, data_di
301
300
assert run_command (f"core install { core } " )
302
301
303
302
# 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" ] )
312
311
313
312
# Copy binaries to same folder
314
313
binaries_dir = Path (data_dir , "build" , "BuiltBinaries" )
0 commit comments