@@ -299,3 +299,44 @@ def test_compile_with_export_binaries_flag(run_command, data_dir):
299
299
assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.hex" ).exists ()
300
300
assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
301
301
assert (sketch_path / "build" / fqbn .replace (":" , "." ) / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
302
+
303
+
304
+ def test_compile_with_custom_build_path (run_command , data_dir ):
305
+ # Init the environment explicitly
306
+ run_command ("core update-index" )
307
+
308
+ # Download latest AVR
309
+ run_command ("core install arduino:avr" )
310
+
311
+ sketch_name = "CompileWithBuildPath"
312
+ sketch_path = Path (data_dir , sketch_name )
313
+ fqbn = "arduino:avr:uno"
314
+
315
+ # Create a test sketch
316
+ result = run_command (f"sketch new { sketch_path } " )
317
+ assert result .ok
318
+ assert f"Sketch created in: { sketch_path } " in result .stdout
319
+
320
+ # Test the --build-path flag with absolute path
321
+ build_path = Path (data_dir , "test_dir" , "build_dir" )
322
+ result = run_command (f"compile -b { fqbn } { sketch_path } --build-path { build_path } " )
323
+ print (result .stderr )
324
+ assert result .ok
325
+
326
+ # Verifies expected binaries have been built to build_path
327
+ assert build_path .exists ()
328
+ assert build_path .is_dir ()
329
+ assert (build_path / f"{ sketch_name } .ino.eep" ).exists ()
330
+ assert (build_path / f"{ sketch_name } .ino.elf" ).exists ()
331
+ assert (build_path / f"{ sketch_name } .ino.hex" ).exists ()
332
+ assert (build_path / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
333
+ assert (build_path / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
334
+
335
+ # Verifies there are no binaries in temp directory
336
+ sketch_path_md5 = hashlib .md5 (bytes (sketch_path )).hexdigest ().upper ()
337
+ build_dir = Path (tempfile .gettempdir (), f"arduino-sketch-{ sketch_path_md5 } " )
338
+ assert not (build_dir / f"{ sketch_name } .ino.eep" ).exists ()
339
+ assert not (build_dir / f"{ sketch_name } .ino.elf" ).exists ()
340
+ assert not (build_dir / f"{ sketch_name } .ino.hex" ).exists ()
341
+ assert not (build_dir / f"{ sketch_name } .ino.with_bootloader.bin" ).exists ()
342
+ assert not (build_dir / f"{ sketch_name } .ino.with_bootloader.hex" ).exists ()
0 commit comments