@@ -125,15 +125,17 @@ func compileWithSimpleSketch(t *testing.T, env *integrationtest.Environment, cli
125
125
126
126
func compileWithCachePurgeNeeded (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
127
127
// create directories that must be purged
128
- baseDir := paths .TempDir ().Join ("arduino" , "sketches" )
128
+ out , _ , err := cli .Run ("config" , "get" , "build_cache.path" )
129
+ require .NoError (t , err )
130
+ cacheDir := paths .New (strings .TrimSpace (string (out ))).Join ("sketches" )
129
131
130
132
// purge case: last used file too old
131
- oldDir1 := baseDir .Join ("test_old_sketch_1" )
133
+ oldDir1 := cacheDir .Join ("test_old_sketch_1" )
132
134
require .NoError (t , oldDir1 .MkdirAll ())
133
135
require .NoError (t , oldDir1 .Join (".last-used" ).WriteFile ([]byte {}))
134
136
require .NoError (t , oldDir1 .Join (".last-used" ).Chtimes (time .Now (), time .Unix (0 , 0 )))
135
137
// no purge case: last used file not existing
136
- missingFileDir := baseDir .Join ("test_sketch_2" )
138
+ missingFileDir := cacheDir .Join ("test_sketch_2" )
137
139
require .NoError (t , missingFileDir .MkdirAll ())
138
140
139
141
defer oldDir1 .RemoveAll ()
@@ -172,12 +174,13 @@ func compileWithSimpleSketchCustomEnv(t *testing.T, env *integrationtest.Environ
172
174
require .NoError (t , err )
173
175
require .NotEmpty (t , compileOutput ["compiler_out" ])
174
176
require .Empty (t , compileOutput ["compiler_err" ])
177
+ builderResult := compileOutput ["builder_result" ].(map [string ]any )
178
+ buildDir := paths .New (builderResult ["build_path" ].(string ))
175
179
176
180
// Verifies expected binaries have been built
177
181
md5 := md5 .Sum (([]byte (sketchPath .String ())))
178
182
sketchPathMd5 := strings .ToUpper (hex .EncodeToString (md5 [:]))
179
183
require .NotEmpty (t , sketchPathMd5 )
180
- buildDir := paths .TempDir ().Join ("arduino" , "sketches" , sketchPathMd5 )
181
184
require .FileExists (t , buildDir .Join (sketchName + ".ino.eep" ).String ())
182
185
require .FileExists (t , buildDir .Join (sketchName + ".ino.elf" ).String ())
183
186
require .FileExists (t , buildDir .Join (sketchName + ".ino.hex" ).String ())
@@ -427,11 +430,16 @@ func compileWithOutputDirFlag(t *testing.T, env *integrationtest.Environment, cl
427
430
_ , _ , err = cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--output-dir" , outputDir .String ())
428
431
require .NoError (t , err )
429
432
433
+ // Get default build cache dir
434
+ out , _ , err := cli .Run ("config" , "get" , "build_cache.path" )
435
+ require .NoError (t , err )
436
+ buildCache := paths .New (strings .TrimSpace (string (out )))
437
+
430
438
// Verifies expected binaries have been built
431
439
md5 := md5 .Sum (([]byte (sketchPath .String ())))
432
440
sketchPathMd5 := strings .ToUpper (hex .EncodeToString (md5 [:]))
433
441
require .NotEmpty (t , sketchPathMd5 )
434
- buildDir := paths . TempDir (). Join ("arduino" , "sketches" , sketchPathMd5 )
442
+ buildDir := buildCache . Join ("sketches" , sketchPathMd5 )
435
443
require .FileExists (t , buildDir .Join (sketchName + ".ino.eep" ).String ())
436
444
require .FileExists (t , buildDir .Join (sketchName + ".ino.elf" ).String ())
437
445
require .FileExists (t , buildDir .Join (sketchName + ".ino.hex" ).String ())
@@ -1008,14 +1016,15 @@ func compileWithInvalidBuildOptionJson(t *testing.T, env *integrationtest.Enviro
1008
1016
_ , _ , err := cli .Run ("sketch" , "new" , sketchPath .String ())
1009
1017
require .NoError (t , err )
1010
1018
1011
- // Get the build directory
1012
- md5 := md5 .Sum (([]byte (sketchPath .String ())))
1013
- sketchPathMd5 := strings .ToUpper (hex .EncodeToString (md5 [:]))
1014
- require .NotEmpty (t , sketchPathMd5 )
1015
- buildDir := paths .TempDir ().Join ("arduino" , "sketches" , sketchPathMd5 )
1016
-
1017
- _ , _ , err = cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--verbose" )
1019
+ out , _ , err := cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--json" )
1018
1020
require .NoError (t , err )
1021
+ var builderOutput struct {
1022
+ BuilderResult struct {
1023
+ BuildPath string `json:"build_path"`
1024
+ } `json:"builder_result"`
1025
+ }
1026
+ require .NoError (t , json .Unmarshal (out , & builderOutput ))
1027
+ buildDir := paths .New (builderOutput .BuilderResult .BuildPath )
1019
1028
1020
1029
// Breaks the build.options.json file
1021
1030
buildOptionsJson := buildDir .Join ("build.options.json" )
0 commit comments