@@ -62,6 +62,12 @@ func TestBuilderEmptySketch(t *testing.T) {
6262
6363 ctx .DebugLevel = 10
6464
65+ // Cleanup cached core
66+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
67+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
68+ os .Remove (coreFile )
69+
70+ // Run builder
6571 command := builder.Builder {}
6672 err := command .Run (ctx )
6773 NoError (t , err )
@@ -95,6 +101,12 @@ func TestBuilderBridge(t *testing.T) {
95101 buildPath := SetupBuildPath (t , ctx )
96102 defer os .RemoveAll (buildPath )
97103
104+ // Cleanup cached core
105+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
106+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
107+ os .Remove (coreFile )
108+
109+ // Run builder
98110 command := builder.Builder {}
99111 err := command .Run (ctx )
100112 NoError (t , err )
@@ -129,14 +141,16 @@ func TestBuilderSketchWithConfig(t *testing.T) {
129141 buildPath := SetupBuildPath (t , ctx )
130142 defer os .RemoveAll (buildPath )
131143
144+ // Cleanup cached core
145+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
146+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
147+ os .Remove (coreFile )
148+
149+ // Run builder
132150 command := builder.Builder {}
133151 err := command .Run (ctx )
134152 NoError (t , err )
135153
136- // Cleanup cached core
137- coreFile := builder_utils .GetCoreArchivePath (ctx .FQBN )
138- os .Remove (coreFile )
139-
140154 _ , err = os .Stat (filepath .Join (buildPath , constants .FOLDER_CORE , "HardwareSerial.cpp.o" ))
141155 NoError (t , err )
142156 _ , err = os .Stat (filepath .Join (buildPath , constants .FOLDER_PREPROC , constants .FILE_CTAGS_TARGET_FOR_GCC_MINUS_E ))
@@ -167,18 +181,21 @@ func TestBuilderBridgeTwice(t *testing.T) {
167181 buildPath := SetupBuildPath (t , ctx )
168182 defer os .RemoveAll (buildPath )
169183
184+ // Cleanup cached core
185+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
186+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
187+ os .Remove (coreFile )
188+
189+ // Run builder
170190 command := builder.Builder {}
171191 err := command .Run (ctx )
172192 NoError (t , err )
173193
194+ // Run builder again
174195 command = builder.Builder {}
175196 err = command .Run (ctx )
176197 NoError (t , err )
177198
178- // Cleanup cached core
179- coreFile := builder_utils .GetCoreArchivePath (ctx .FQBN )
180- os .Remove (coreFile )
181-
182199 _ , err = os .Stat (filepath .Join (buildPath , constants .FOLDER_CORE , "HardwareSerial.cpp.o" ))
183200 NoError (t , err )
184201 _ , err = os .Stat (filepath .Join (buildPath , constants .FOLDER_PREPROC , constants .FILE_CTAGS_TARGET_FOR_GCC_MINUS_E ))
@@ -211,6 +228,12 @@ func TestBuilderBridgeSAM(t *testing.T) {
211228
212229 ctx .WarningsLevel = "all"
213230
231+ // Cleanup cached core
232+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "sam" )
233+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
234+ os .Remove (coreFile )
235+
236+ // Run builder
214237 command := builder.Builder {}
215238 err := command .Run (ctx )
216239 NoError (t , err )
@@ -254,6 +277,12 @@ func TestBuilderBridgeRedBearLab(t *testing.T) {
254277 buildPath := SetupBuildPath (t , ctx )
255278 defer os .RemoveAll (buildPath )
256279
280+ // Cleanup cached core
281+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
282+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
283+ os .Remove (coreFile )
284+
285+ // Run builder
257286 command := builder.Builder {}
258287 err := command .Run (ctx )
259288 NoError (t , err )
@@ -404,10 +433,19 @@ func TestBuilderWithBuildPathInSketchDir(t *testing.T) {
404433 NoError (t , err )
405434 defer os .RemoveAll (ctx .BuildPath )
406435
436+ // Cleanup cached core
437+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
438+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
439+ os .Remove (coreFile )
440+
441+ // Run build
407442 command := builder.Builder {}
408443 err = command .Run (ctx )
409444 NoError (t , err )
410445
446+ // Cleanup cached core
447+ os .Remove (coreFile )
448+
411449 // Run build twice, to verify the build still works when the
412450 // build directory is present at the start
413451 err = command .Run (ctx )
@@ -430,7 +468,8 @@ func TestBuilderCacheCoreAFile(t *testing.T) {
430468 defer os .RemoveAll (ctx .BuildPath )
431469
432470 // Cleanup cached core
433- coreFile := builder_utils .GetCoreArchivePath (ctx .FQBN )
471+ coreFolder := filepath .Join ("downloaded_hardware" , "arduino" , "avr" )
472+ coreFile := builder_utils .GetCachedCoreArchiveFileName (ctx .FQBN , coreFolder )
434473 os .Remove (coreFile )
435474
436475 // Run build
@@ -451,7 +490,7 @@ func TestBuilderCacheCoreAFile(t *testing.T) {
451490 // Touch a file of the core and check if the builder invalidate the cache
452491 time .Sleep (time .Second )
453492 now := time .Now ().Local ()
454- err = os .Chtimes (filepath .Join ("downloaded_hardware" , "arduino" , "avr" , "cores" , "arduino" , "Arduino.h" ), now , now )
493+ err = os .Chtimes (filepath .Join (coreFolder , "cores" , "arduino" , "Arduino.h" ), now , now )
455494 require .NoError (t , err )
456495
457496 // Run build again, to verify that the builder rebuilds core.a
0 commit comments