@@ -18,6 +18,7 @@ package core_test
1818import (
1919 "crypto/md5"
2020 "encoding/hex"
21+ "encoding/json"
2122 "fmt"
2223 "os"
2324 "path/filepath"
@@ -1303,3 +1304,50 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
13031304 require .Contains (t , lines , []string {"incompatible_vendor:avr" , "n/a" , "Incompatible" , "Boards" })
13041305 }
13051306}
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:avr@1.8.6" )
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