diff --git a/go.mod b/go.mod index e495b5a2e7a..7481a151b00 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( go.bug.st/cleanup v1.0.0 go.bug.st/downloader/v2 v2.2.0 go.bug.st/relaxed-semver v0.12.0 - go.bug.st/testifyjson v1.1.1 + go.bug.st/testifyjson v1.2.0 golang.org/x/term v0.22.0 golang.org/x/text v0.16.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 diff --git a/go.sum b/go.sum index 7c8bc44a9e8..c3ff0cd2e62 100644 --- a/go.sum +++ b/go.sum @@ -219,8 +219,8 @@ go.bug.st/relaxed-semver v0.12.0 h1:se8v3lTdAAFp68+/RS/0Y/nFdnpdzkP5ICY04SPau4E= go.bug.st/relaxed-semver v0.12.0/go.mod h1:Cpcbiig6Omwlq6bS7i3MQWiqS7W7HDd8CAnZFC40Cl0= go.bug.st/serial v1.6.1 h1:VSSWmUxlj1T/YlRo2J104Zv3wJFrjHIl/T3NeruWAHY= go.bug.st/serial v1.6.1/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE= -go.bug.st/testifyjson v1.1.1 h1:nHotIMK151LF3vYsU/b2RaoVaWCgrf2kvQeGNoZkGaA= -go.bug.st/testifyjson v1.1.1/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI= +go.bug.st/testifyjson v1.2.0 h1:0pAfOUMVCOJ6bb9JcC4UmnACjxwxv2Ojb6Z9chaQBjg= +go.bug.st/testifyjson v1.2.0/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index fbda8da1c0c..1f8850f0856 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -18,6 +18,7 @@ package core_test import ( "crypto/md5" "encoding/hex" + "encoding/json" "fmt" "os" "path/filepath" @@ -1303,3 +1304,50 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) { require.Contains(t, lines, []string{"incompatible_vendor:avr", "n/a", "Incompatible", "Boards"}) } } + +func TestReferencedCoreBuildAndRuntimeProperties(t *testing.T) { + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + _, _, err := cli.Run("core", "install", "arduino:avr@1.8.6") + require.NoError(t, err) + + testSketchbook, err := paths.New("testdata", "sketchbook_with_extended_platform").Abs() + require.NoError(t, err) + + // Install custom platform + err = testSketchbook.Join("hardware").CopyDirTo(cli.SketchbookDir().Join("hardware")) + require.NoError(t, err) + + // Determine some useful paths + boardPlatformPath := cli.SketchbookDir().Join("hardware", "test", "avr").String() + corePlatformPath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6").String() + corePath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6", "cores", "arduino").String() + + jsonEncode := func(in string) string { + enc, err := json.Marshal(in) + require.NoError(t, err) + return string(enc) + } + + // Check runtime variables are populated correctly + { + outJson, _, err := cli.Run("board", "details", "-b", "test:avr:test", "--show-properties", "--json") + require.NoError(t, err) + out := requirejson.Parse(t, outJson).Query(".build_properties") + out.ArrayMustContain(jsonEncode("build.board.platform.path=" + boardPlatformPath)) + out.ArrayMustContain(jsonEncode("build.core.platform.path=" + corePlatformPath)) + out.ArrayMustContain(jsonEncode("build.core.path=" + corePath)) + out.ArrayMustContain(jsonEncode("runtime.platform.path=" + boardPlatformPath)) + } + { + outJson, _, err := cli.Run("board", "details", "-b", "test:avr:test2", "--show-properties", "--json") + require.NoError(t, err) + out := requirejson.Parse(t, outJson).Query(".build_properties") + out.ArrayMustContain(jsonEncode("build.board.platform.path=" + boardPlatformPath)) + out.ArrayMustContain(jsonEncode("build.core.platform.path=" + corePlatformPath)) + out.ArrayMustContain(jsonEncode("build.core.path=" + corePath)) + // https://github.com/arduino/arduino-cli/issues/2616 + out.ArrayMustContain(jsonEncode("runtime.platform.path=" + corePlatformPath)) + } +} diff --git a/internal/integrationtest/core/testdata/sketchbook_with_extended_platform/hardware/test/avr/boards.txt b/internal/integrationtest/core/testdata/sketchbook_with_extended_platform/hardware/test/avr/boards.txt new file mode 100644 index 00000000000..24f046b561a --- /dev/null +++ b/internal/integrationtest/core/testdata/sketchbook_with_extended_platform/hardware/test/avr/boards.txt @@ -0,0 +1,7 @@ + +test.name=Test Board +test.build.core=arduino:arduino + +test2.name=Test 2 Board +test2.build.core=arduino:arduino +test2.runtime.use_core_platform_path_for_runtime_platform_path=true