@@ -340,3 +340,74 @@ def test_compile_with_custom_build_path(run_command, data_dir):
340
340
assert not (build_dir / f"{ sketch_name } .ino.hex" ).exists ()
341
341
assert not (build_dir / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
342
342
assert not (build_dir / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
343
+
344
+
345
+ def test_compile_with_export_binaries_env_var (run_command , data_dir , downloads_dir ):
346
+ # Init the environment explicitly
347
+ run_command ("core update-index" )
348
+
349
+ # Download latest AVR
350
+ run_command ("core install arduino:avr" )
351
+
352
+ sketch_name = "CompileWithExportBinariesEnvVar"
353
+ sketch_path = Path (data_dir , sketch_name )
354
+ fqbn = "arduino:avr:uno"
355
+
356
+ # Create a test sketch
357
+ assert run_command ("sketch new {}" .format (sketch_path ))
358
+
359
+ env = {
360
+ "ARDUINO_DATA_DIR" : data_dir ,
361
+ "ARDUINO_DOWNLOADS_DIR" : downloads_dir ,
362
+ "ARDUINO_SKETCHBOOK_DIR" : data_dir ,
363
+ "ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES" : "true" ,
364
+ }
365
+ # Test compilation with export binaries env var set
366
+ result = run_command (f"compile -b { fqbn } { sketch_path } " , custom_env = env )
367
+ assert result .ok
368
+ assert Path (sketch_path , "build" ).exists ()
369
+ assert Path (sketch_path , "build" ).is_dir ()
370
+
371
+ # Verifies binaries are exported when export binaries env var is set
372
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.eep" ).exists ()
373
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.elf" ).exists ()
374
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.hex" ).exists ()
375
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
376
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
377
+
378
+
379
+ def test_compile_with_export_binaries_config (run_command , data_dir , downloads_dir ):
380
+ # Init the environment explicitly
381
+ run_command ("core update-index" )
382
+
383
+ # Download latest AVR
384
+ run_command ("core install arduino:avr" )
385
+
386
+ sketch_name = "CompileWithExportBinariesConfig"
387
+ sketch_path = Path (data_dir , sketch_name )
388
+ fqbn = "arduino:avr:uno"
389
+
390
+ # Create a test sketch
391
+ assert run_command ("sketch new {}" .format (sketch_path ))
392
+
393
+ # Create settings with export binaries set to true
394
+ env = {
395
+ "ARDUINO_DATA_DIR" : data_dir ,
396
+ "ARDUINO_DOWNLOADS_DIR" : downloads_dir ,
397
+ "ARDUINO_SKETCHBOOK_DIR" : data_dir ,
398
+ "ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES" : "true" ,
399
+ }
400
+ assert run_command ("config init --dest-dir ." , custom_env = env )
401
+
402
+ # Test compilation with export binaries env var set
403
+ result = run_command (f"compile -b { fqbn } { sketch_path } " )
404
+ assert result .ok
405
+ assert Path (sketch_path , "build" ).exists ()
406
+ assert Path (sketch_path , "build" ).is_dir ()
407
+
408
+ # Verifies binaries are exported when export binaries env var is set
409
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.eep" ).exists ()
410
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.elf" ).exists ()
411
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.hex" ).exists ()
412
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
413
+ assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
0 commit comments