@@ -19,6 +19,7 @@ import (
19
19
"crypto/md5"
20
20
"encoding/hex"
21
21
"encoding/json"
22
+ "fmt"
22
23
"os"
23
24
"sort"
24
25
"strings"
@@ -1220,6 +1221,28 @@ func buildWithCustomBuildPath(t *testing.T, env *integrationtest.Environment, cl
1220
1221
// Run build twice, to verify the build still works when the build directory is present at the start
1221
1222
_ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--build-path" , buildPath .String (), sketchPath .String ())
1222
1223
require .NoError (t , err )
1224
+
1225
+ // Run again a couple of times with a different build path, to verify that old build
1226
+ // path is not copied back in the sketch build recursively.
1227
+ // https://github.com/arduino/arduino-cli/issues/2266
1228
+ secondBuildPath := sketchPath .Join ("build2" )
1229
+ _ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--build-path" , secondBuildPath .String (), sketchPath .String ())
1230
+ require .NoError (t , err )
1231
+ _ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--build-path" , buildPath .String (), sketchPath .String ())
1232
+ require .NoError (t , err )
1233
+ _ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--build-path" , secondBuildPath .String (), sketchPath .String ())
1234
+ require .NoError (t , err )
1235
+ _ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--build-path" , buildPath .String (), sketchPath .String ())
1236
+ require .NoError (t , err )
1237
+
1238
+ // Print build path content for debugging purposes
1239
+ bp , _ := buildPath .ReadDirRecursive ()
1240
+ fmt .Println ("Build path content:" )
1241
+ for _ , file := range bp {
1242
+ fmt .Println ("> " , file .String ())
1243
+ }
1244
+
1245
+ require .False (t , buildPath .Join ("sketch" , "build2" , "sketch" ).Exist ())
1223
1246
})
1224
1247
1225
1248
t .Run ("SameAsSektch" , func (t * testing.T ) {
0 commit comments