@@ -18,6 +18,7 @@ package core_test
18
18
import (
19
19
"crypto/md5"
20
20
"encoding/hex"
21
+ "encoding/json"
21
22
"fmt"
22
23
"os"
23
24
"path/filepath"
@@ -1303,3 +1304,50 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1303
1304
require .Contains (t , lines , []string {"incompatible_vendor:avr" , "n/a" , "Incompatible" , "Boards" })
1304
1305
}
1305
1306
}
1307
+
1308
+ func TestReferencedCoreBuildAndRuntimeProperties (t * testing.T ) {
1309
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
1310
+ defer env .CleanUp ()
1311
+
1312
+ _ ,
_ ,
err := cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
1313
+ require .NoError (t , err )
1314
+
1315
+ testSketchbook , err := paths .New ("testdata" , "sketchbook_with_extended_platform" ).Abs ()
1316
+ require .NoError (t , err )
1317
+
1318
+ // Install custom platform
1319
+ err = testSketchbook .Join ("hardware" ).CopyDirTo (cli .SketchbookDir ().Join ("hardware" ))
1320
+ require .NoError (t , err )
1321
+
1322
+ // Determine some useful paths
1323
+ boardPlatformPath := cli .SketchbookDir ().Join ("hardware" , "test" , "avr" ).String ()
1324
+ corePlatformPath := cli .DataDir ().Join ("packages" , "arduino" , "hardware" , "avr" , "1.8.6" ).String ()
1325
+ corePath := cli .DataDir ().Join ("packages" , "arduino" , "hardware" , "avr" , "1.8.6" , "cores" , "arduino" ).String ()
1326
+
1327
+ jsonEncode := func (in string ) string {
1328
+ enc , err := json .Marshal (in )
1329
+ require .NoError (t , err )
1330
+ return string (enc )
1331
+ }
1332
+
1333
+ // Check runtime variables are populated correctly
1334
+ {
1335
+ outJson , _ , err := cli .Run ("board" , "details" , "-b" , "test:avr:test" , "--show-properties" , "--json" )
1336
+ require .NoError (t , err )
1337
+ out := requirejson .Parse (t , outJson ).Query (".build_properties" )
1338
+ out .ArrayMustContain (jsonEncode ("build.board.platform.path=" + boardPlatformPath ))
1339
+ out .ArrayMustContain (jsonEncode ("build.core.platform.path=" + corePlatformPath ))
1340
+ out .ArrayMustContain (jsonEncode ("build.core.path=" + corePath ))
1341
+ out .ArrayMustContain (jsonEncode ("runtime.platform.path=" + boardPlatformPath ))
1342
+ }
1343
+ {
1344
+ outJson , _ , err := cli .Run ("board" , "details" , "-b" , "test:avr:test2" , "--show-properties" , "--json" )
1345
+ require .NoError (t , err )
1346
+ out := requirejson .Parse (t , outJson ).Query (".build_properties" )
1347
+ out .ArrayMustContain (jsonEncode ("build.board.platform.path=" + boardPlatformPath ))
1348
+ out .ArrayMustContain (jsonEncode ("build.core.platform.path=" + corePlatformPath ))
1349
+ out .ArrayMustContain (jsonEncode ("build.core.path=" + corePath ))
1350
+ // https://github.com/arduino/arduino-cli/issues/2616
1351
+ out .ArrayMustContain (jsonEncode ("runtime.platform.path=" + corePlatformPath ))
1352
+ }
1353
+ }
0 commit comments