@@ -328,7 +328,7 @@ func testBuilderBridgeExample(t *testing.T, env *integrationtest.Environment, cl
328
328
require .Equal (t , "Bridge" , libs [0 ])
329
329
330
330
// Build again...
331
- out2 , err2 := tryBuild (t , env , cli , "arduino:avr:leonardo" , "no-clean" )
331
+ out2 , err2 := tryBuild (t , env , cli , "arduino:avr:leonardo" , & buildOptions { NoClean : true } )
332
332
require .NoError (t , err2 )
333
333
buildPath2 := out2 .BuilderResult .BuildPath
334
334
require .True (t , buildPath2 .Join ("core" , "HardwareSerial.cpp.o" ).Exist ())
@@ -340,7 +340,7 @@ func testBuilderBridgeExample(t *testing.T, env *integrationtest.Environment, cl
340
340
341
341
t .Run ("BuildForSAM" , func (t * testing.T ) {
342
342
// Build again for SAM...
343
- out , err := tryBuild (t , env , cli , "arduino:sam:arduino_due_x_dbg" , "all-warnings" )
343
+ out , err := tryBuild (t , env , cli , "arduino:sam:arduino_due_x_dbg" , & buildOptions { AllWarnings : true } )
344
344
require .NoError (t , err )
345
345
346
346
buildPath := out .BuilderResult .BuildPath
@@ -363,7 +363,7 @@ func testBuilderBridgeExample(t *testing.T, env *integrationtest.Environment, cl
363
363
364
364
t .Run ("BuildForRedBearAVR" , func (t * testing.T ) {
365
365
// Build again for RedBearLab...
366
- out , err := tryBuild (t , env , cli , "RedBear:avr:blend" , "verbose" )
366
+ out , err := tryBuild (t , env , cli , "RedBear:avr:blend" , & buildOptions { Verbose : true } )
367
367
require .NoError (t , err )
368
368
buildPath := out .BuilderResult .BuildPath
369
369
require .True (t , buildPath .Join ("core" , "HardwareSerial.cpp.o" ).Exist ())
@@ -382,7 +382,7 @@ func testBuilderBridgeExample(t *testing.T, env *integrationtest.Environment, cl
382
382
require .NoError (t , buildPath .Join ("libraries" , "SPI" ).MkdirAll ())
383
383
384
384
// Build again...
385
- _ , err = tryBuild (t , env , cli , "arduino:avr:leonardo" , "no-clean" )
385
+ _ , err = tryBuild (t , env , cli , "arduino:avr:leonardo" , & buildOptions { NoClean : true } )
386
386
require .NoError (t , err )
387
387
388
388
require .False (t , buildPath .Join ("libraries" , "SPI" ).Exist ())
@@ -586,25 +586,41 @@ type builderLibrary struct {
586
586
SourceDir * paths.Path `json:"source_dir"`
587
587
}
588
588
589
- func tryBuild (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI , fqbn string , options ... string ) (* builderOutput , error ) {
589
+ type buildOptions struct {
590
+ Sketch * paths.Path
591
+ NoClean bool
592
+ AllWarnings bool
593
+ Verbose bool
594
+ }
595
+
596
+ func tryBuild (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI , fqbn string , optionsArg ... * buildOptions ) (* builderOutput , error ) {
590
597
subTestName := strings .Split (t .Name (), "/" )[1 ]
591
- sketchPath , err := paths .New ("testdata" , subTestName ).Abs ()
592
- require .NoError (t , err )
598
+ var options * buildOptions
599
+ if len (optionsArg ) == 0 {
600
+ sketchPath , err := paths .New ("testdata" , subTestName ).Abs ()
601
+ require .NoError (t , err )
602
+ options = & buildOptions {
603
+ Sketch : sketchPath ,
604
+ }
605
+ } else {
606
+ require .Len (t , optionsArg , 1 )
607
+ options = optionsArg [0 ]
608
+ }
593
609
libsPath , err := paths .New ("testdata" , "libraries" ).Abs ()
594
610
require .NoError (t , err )
595
611
args := []string {
596
612
"compile" ,
597
613
"-b" , fqbn ,
598
614
"--libraries" , libsPath .String (),
599
615
"--format" , "json" ,
600
- sketchPath .String ()}
601
- if ! slices . Contains ( options , "no-clean" ) {
616
+ options . Sketch .String ()}
617
+ if ! options . NoClean {
602
618
args = append (args , "--clean" )
603
619
}
604
- if slices . Contains ( options , "all-warnings" ) {
620
+ if options . AllWarnings {
605
621
args = append (args , "--warnings" , "all" )
606
622
}
607
- if slices . Contains ( options , "verbose" ) {
623
+ if options . Verbose {
608
624
args = append (args , "-v" )
609
625
}
610
626
jsonOut , _ , err := cli .Run (args ... )
0 commit comments