@@ -415,3 +415,93 @@ func TestCompileWithBuildPropertyContainingQuotes(t *testing.T) {
415415 require .NoError (t , err )
416416 require .Contains (t , string (stdout ), `-DMY_DEFINE=\"hello world\"` )
417417}
418+
419+ func TestCompileWithMultipleBuildPropertyFlags (t * testing.T ) {
420+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
421+ defer env .CleanUp ()
422+
423+ // Init the environment explicitly
424+ _ , _ , err := cli .Run ("core" , "update-index" )
425+ require .NoError (t , err )
426+
427+ // Install Arduino AVR Boards
428+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.3" )
429+ require .NoError (t , err )
430+
431+ // Copy sketch
432+ sketchName := "sketch_with_multiple_defines"
433+ p , err := paths .Getwd ()
434+ require .NoError (t , err )
435+ require .NotNil (t , p )
436+ testSketch := p .Parent ().Join ("testdata" , sketchName )
437+ sketchPath := cli .SketchbookDir ().Join (sketchName )
438+ err = testSketch .CopyDirTo (sketchPath )
439+ require .NoError (t , err )
440+
441+ fqbn := "arduino:avr:uno"
442+
443+ // Compile using multiple build properties separated by a space
444+ _ , _ , err = cli .Run (
445+ "compile" ,
446+ "-b" ,
447+ fqbn ,
448+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2 -DSSID=\" This is a String\" \" " ,
449+ sketchPath .String (),
450+ "--verbose" ,
451+ "--clean" ,
452+ )
453+ require .Error (t , err )
454+
455+ // Compile using multiple build properties separated by a space and properly quoted
456+ stdout , _ , err := cli .Run (
457+ "compile" ,
458+ "-b" ,
459+ fqbn ,
460+ "--build-property=compiler.cpp.extra_flags=-DPIN=2 \" -DSSID=\" This is a String\" \" " ,
461+ sketchPath .String (),
462+ "--verbose" ,
463+ "--clean" ,
464+ )
465+ require .NoError (t , err )
466+ require .Contains (t , string (stdout ), "-DPIN=2 \" -DSSID=\\ \" This is a String\\ \" \" " )
467+
468+ // Tries compilation using multiple build properties separated by a comma
469+ _ , _ , err = cli .Run (
470+ "compile" ,
471+ "-b" ,
472+ fqbn ,
473+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2,-DSSID=\" This is a String\" \" " ,
474+ sketchPath .String (),
475+ "--verbose" ,
476+ "--clean" ,
477+ )
478+ require .Error (t , err )
479+
480+ stdout , _ , err = cli .Run (
481+ "compile" ,
482+ "-b" ,
483+ fqbn ,
484+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2\" " ,
485+ "--build-property=compiler.cpp.extra_flags=\" -DSSID=\" This is a String\" \" " ,
486+ sketchPath .String (),
487+ "--verbose" ,
488+ "--clean" ,
489+ )
490+ require .Error (t , err )
491+ require .NotContains (t , string (stdout ), "-DPIN=2" )
492+ require .Contains (t , string (stdout ), "-DSSID=\\ \" This is a String\\ \" " )
493+
494+ stdout , _ , err = cli .Run (
495+ "compile" ,
496+ "-b" ,
497+ fqbn ,
498+ "--build-property=compiler.cpp.extra_flags=\" -DPIN=2\" " ,
499+ "--build-property=build.extra_flags=\" -DSSID=\" hello world\" \" " ,
500+ sketchPath .String (),
501+ "--verbose" ,
502+ "--clean" ,
503+ )
504+ require .NoError (t , err )
505+ require .Contains (t , string (stdout ), "-DPIN=2" )
506+ require .Contains (t , string (stdout ), "-DSSID=\\ \" hello world\\ \" " )
507+ }
0 commit comments