@@ -143,3 +143,43 @@ func TestCompileSketchCaseMismatchFails(t *testing.T) {
143
143
require .Error (t , err )
144
144
require .Contains (t , string (stderr ), "Error opening sketch:" )
145
145
}
146
+
147
+ func TestCompileWithOnlyCompilationDatabaseFlag (t * testing.T ) {
148
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
149
+ defer env .CleanUp ()
150
+
151
+ _ , _ , err := cli .Run ("update" )
152
+ require .NoError (t , err )
153
+
154
+ _ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
155
+ require .NoError (t , err )
156
+
157
+ sketchName := "CompileSketchOnlyCompilationDatabaseFlag"
158
+ sketchPath := cli .SketchbookDir ().Join (sketchName )
159
+ fqbn := "arduino:avr:uno"
160
+
161
+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
162
+ require .NoError (t , err )
163
+
164
+ // Verifies no binaries exist
165
+ buildPath := sketchPath .Join ("build" )
166
+ require .NoDirExists (t , buildPath .String ())
167
+
168
+ // Compile with both --export-binaries and --only-compilation-database flags
169
+ _ , _ , err = cli .Run ("compile" , "--export-binaries" , "--only-compilation-database" , "--clean" , "-b" , fqbn , sketchPath .String ())
170
+ require .NoError (t , err )
171
+
172
+ // Verifies no binaries are exported
173
+ require .NoDirExists (t , buildPath .String ())
174
+
175
+ // Verifies no binaries exist
176
+ buildPath = cli .SketchbookDir ().Join ("export-dir" )
177
+ require .NoDirExists (t , buildPath .String ())
178
+
179
+ // Compile by setting the --output-dir flag and --only-compilation-database flags
180
+ _ , _ , err = cli .Run ("compile" , "--output-dir" , buildPath .String (), "--only-compilation-database" , "--clean" , "-b" , fqbn , sketchPath .String ())
181
+ require .NoError (t , err )
182
+
183
+ // Verifies no binaries are exported
184
+ require .NoDirExists (t , buildPath .String ())
185
+ }
0 commit comments