@@ -726,3 +726,35 @@ def test_compile_sketch_case_mismatch_fails(run_command, data_dir):
726726 res = run_command (f"compile --clean -b { fqbn } " , custom_working_dir = sketch_path )
727727 assert res .failed
728728 assert "Error during build: opening sketch: no valid sketch found" in res .stderr
729+
730+
731+ def test_compile_with_only_compilation_database_flag (run_command , data_dir ):
732+ assert run_command ("update" )
733+
734+ assert run_command ("core install arduino:avr@1.8.3" )
735+
736+ sketch_name = "CompileSketchOnlyCompilationDatabaseFlag"
737+ sketch_path = Path (data_dir , sketch_name )
738+ fqbn = "arduino:avr:uno"
739+
740+ assert run_command (f"sketch new { sketch_path } " )
741+
742+ # Verifies no binaries exist
743+ build_path = Path (sketch_path , "build" )
744+ assert not build_path .exists ()
745+
746+ # Compile with both --export-binaries and --only-compilation-database flags
747+ assert run_command (f"compile --export-binaries --only-compilation-database --clean -b { fqbn } { sketch_path } " )
748+
749+ # Verifies no binaries are exported
750+ assert not build_path .exists ()
751+
752+ # Verifies no binaries exist
753+ build_path = Path (data_dir , "export-dir" )
754+ assert not build_path .exists ()
755+
756+ # Compile by setting the --output-dir flag and --only-compilation-database flags
757+ assert run_command (f"compile --output-dir { build_path } --only-compilation-database --clean -b { fqbn } { sketch_path } " )
758+
759+ # Verifies no binaries are exported
760+ assert not build_path .exists ()
0 commit comments