@@ -391,3 +391,85 @@ func TestCompileWithBuildPropertyContainingQuotes(t *testing.T) {
391
391
require .NoError (t , err )
392
392
require .Contains (t , string (stdout ), `-DMY_DEFINE=\"hello world\"` )
393
393
}
394
+
395
+ func TestCompileWithMultipleBuildPropertyFlags (t * testing.T ) {
396
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
397
+ defer env .CleanUp ()
398
+
399
+ // Init the environment explicitly
400
+ _ , _ , err := cli .Run ("core" , "update-index" )
401
+ require .NoError (t , err )
402
+
403
+ // Install Arduino AVR Boards
404
+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.3" )
405
+ require .NoError (t , err )
406
+
407
+ sketchName := "sketch_with_multiple_defines"
408
+ sketchPath := cli .CopySketch (sketchName )
409
+ fqbn := "arduino:avr:uno"
410
+
411
+ // Compile using multiple build properties separated by a space
412
+ _ , _ , err = cli .Run (
413
+ "compile" ,
414
+ "-b" ,
415
+ fqbn ,
416
+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2 -DSSID=\" This is a String\" \" " ,
417
+ sketchPath .String (),
418
+ "--verbose" ,
419
+ "--clean" ,
420
+ )
421
+ require .Error (t , err )
422
+
423
+ // Compile using multiple build properties separated by a space and properly quoted
424
+ stdout , _ , err := cli .Run (
425
+ "compile" ,
426
+ "-b" ,
427
+ fqbn ,
428
+ "--build-property=compiler.cpp.extra_flags=-DPIN=2 \" -DSSID=\" This is a String\" \" " ,
429
+ sketchPath .String (),
430
+ "--verbose" ,
431
+ "--clean" ,
432
+ )
433
+ require .NoError (t , err )
434
+ require .Contains (t , string (stdout ), "-DPIN=2 \" -DSSID=\\ \" This is a String\\ \" \" " )
435
+
436
+ // Tries compilation using multiple build properties separated by a comma
437
+ _ , _ , err = cli .Run (
438
+ "compile" ,
439
+ "-b" ,
440
+ fqbn ,
441
+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2,-DSSID=\" This is a String\" \" " ,
442
+ sketchPath .String (),
443
+ "--verbose" ,
444
+ "--clean" ,
445
+ )
446
+ require .Error (t , err )
447
+
448
+ stdout , _ , err = cli .Run (
449
+ "compile" ,
450
+ "-b" ,
451
+ fqbn ,
452
+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2\" " ,
453
+ "--build-property=compiler.cpp.extra_flags=\" -DSSID=\" This is a String\" \" " ,
454
+ sketchPath .String (),
455
+ "--verbose" ,
456
+ "--clean" ,
457
+ )
458
+ require .Error (t , err )
459
+ require .NotContains (t , string (stdout ), "-DPIN=2" )
460
+ require .Contains (t , string (stdout ), "-DSSID=\\ \" This is a String\\ \" " )
461
+
462
+ stdout , _ , err = cli .Run (
463
+ "compile" ,
464
+ "-b" ,
465
+ fqbn ,
466
+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2\" " ,
467
+ "--build-property=build.extra_flags=\" -DSSID=\" hello world\" \" " ,
468
+ sketchPath .String (),
469
+ "--verbose" ,
470
+ "--clean" ,
471
+ )
472
+ require .NoError (t , err )
473
+ require .Contains (t , string (stdout ), "-DPIN=2" )
474
+ require .Contains (t , string (stdout ), "-DSSID=\\ \" hello world\\ \" " )
475
+ }
0 commit comments