@@ -218,3 +218,39 @@ func TestCompileWithConflictingLibrariesInclude(t *testing.T) {
218
218
}
219
219
require .Contains (t , string (stdout ), expectedOutput [0 ]+ "\n " + expectedOutput [1 ]+ "\n " + expectedOutput [2 ]+ "\n " )
220
220
}
221
+
222
+ func TestCompileWithInvalidBuildOptionJson (t * testing.T ) {
223
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
224
+ defer env .CleanUp ()
225
+
226
+ _ , _ , err := cli .Run ("update" )
227
+ require .NoError (t , err )
228
+
229
+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.3" )
230
+ require .NoError (t , err )
231
+
232
+ sketchName := "CompileInvalidBuildOptionsJson"
233
+ sketchPath := cli .SketchbookDir ().Join (sketchName )
234
+ fqbn := "arduino:avr:uno"
235
+
236
+ // Create a test sketch
237
+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
238
+ require .NoError (t , err )
239
+
240
+ // Get the build directory
241
+ md5 := md5 .Sum (([]byte (sketchPath .String ())))
242
+ sketchPathMd5 := strings .ToUpper (hex .EncodeToString (md5 [:]))
243
+ require .NotEmpty (t , sketchPathMd5 )
244
+ buildDir := paths .TempDir ().Join ("arduino-sketch-" + sketchPathMd5 )
245
+
246
+ _ , _ , err = cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--verbose" )
247
+ require .NoError (t , err )
248
+
249
+ // Breaks the build.options.json file
250
+ buildOptionsJson := buildDir .Join ("build.options.json" )
251
+ err = buildOptionsJson .WriteFile ([]byte ("invalid json" ))
252
+ require .NoError (t , err )
253
+
254
+ _ , _ , err = cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--verbose" )
255
+ require .NoError (t , err )
256
+ }
0 commit comments