@@ -250,3 +250,50 @@ func TestCompileAndUploadCombo(t *testing.T) {
250250 runTest (sketchMainFile .String ())
251251 }
252252}
253+
254+ func TestCompileAndUploadComboWithCustomBuildPath (t * testing.T ) {
255+ if os .Getenv ("CI" ) != "" {
256+ t .Skip ("VMs have no serial ports" )
257+ }
258+
259+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
260+ defer env .CleanUp ()
261+
262+ // Init the environment explicitly
263+ _ , _ , err := cli .Run ("core" , "update-index" )
264+ require .NoError (t , err )
265+
266+ // Create a test sketch
267+ sketchName := "CompileAndUploadCustomBuildPathIntegrationTest"
268+ sketchPath := cli .SketchbookDir ().Join (sketchName )
269+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
270+ require .NoError (t , err )
271+
272+ // Build sketch for each detected board
273+ for _ , board := range detectedBoards (t , cli ) {
274+ fqbnNormalized := strings .ReplaceAll (board .fqbn , ":" , "-" )
275+ logFileName := fqbnNormalized + "-compile.log"
276+ logFilePath := cli .SketchbookDir ().Join (logFileName )
277+
278+ _ , _ , err = cli .Run ("core" , "install" , board .core )
279+ require .NoError (t , err )
280+
281+ waitForBoard (t , cli )
282+
283+ buildPath := cli .SketchbookDir ().Join ("test_dir" , fqbnNormalized , "build_dir" )
284+ _ , _ , err := cli .Run ("compile" , "-b" , board .fqbn , "--upload" , "-p" , board .address , "--build-path" , buildPath .String (),
285+ sketchPath .String (), "--log-format" , "json" , "--log-file" , logFilePath .String (), "--log-level" , "trace" )
286+ require .NoError (t , err )
287+ logJson , err := logFilePath .ReadFile ()
288+ require .NoError (t , err )
289+
290+ // check from the logs if the bin file were uploaded on the current board
291+ logJson = []byte ("[" + strings .ReplaceAll (strings .TrimSuffix (string (logJson ), "\n " ), "\n " , "," ) + "]" )
292+ traces := requirejson .Parse (t , logJson ).Query ("[ .[] | select(.level==\" trace\" ) | .msg ]" ).String ()
293+ traces = strings .ReplaceAll (traces , "\\ \\ " , "\\ " )
294+ require .Contains (t , traces , "Compile " + sketchPath .String ()+ " for " + board .fqbn + " started" )
295+ require .Contains (t , traces , "Compile " + sketchName + " for " + board .fqbn + " successful" )
296+ require .Contains (t , traces , "Upload " + sketchPath .String ()+ " on " + board .fqbn + " started" )
297+ require .Contains (t , traces , "Upload successful" )
298+ }
299+ }
0 commit comments