Skip to content

Commit 0b80ef6

Browse files
committed
Added tests
1 parent 8522850 commit 0b80ef6

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
go.bug.st/cleanup v1.0.0
3838
go.bug.st/downloader/v2 v2.2.0
3939
go.bug.st/relaxed-semver v0.12.0
40-
go.bug.st/testifyjson v1.1.1
40+
go.bug.st/testifyjson v1.2.0
4141
golang.org/x/term v0.22.0
4242
golang.org/x/text v0.16.0
4343
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ go.bug.st/relaxed-semver v0.12.0 h1:se8v3lTdAAFp68+/RS/0Y/nFdnpdzkP5ICY04SPau4E=
219219
go.bug.st/relaxed-semver v0.12.0/go.mod h1:Cpcbiig6Omwlq6bS7i3MQWiqS7W7HDd8CAnZFC40Cl0=
220220
go.bug.st/serial v1.6.1 h1:VSSWmUxlj1T/YlRo2J104Zv3wJFrjHIl/T3NeruWAHY=
221221
go.bug.st/serial v1.6.1/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
222-
go.bug.st/testifyjson v1.1.1 h1:nHotIMK151LF3vYsU/b2RaoVaWCgrf2kvQeGNoZkGaA=
223-
go.bug.st/testifyjson v1.1.1/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI=
222+
go.bug.st/testifyjson v1.2.0 h1:0pAfOUMVCOJ6bb9JcC4UmnACjxwxv2Ojb6Z9chaQBjg=
223+
go.bug.st/testifyjson v1.2.0/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI=
224224
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
225225
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
226226
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=

internal/integrationtest/core/core_test.go

+48
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core_test
1818
import (
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:[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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
test.name=Test Board
3+
test.build.core=arduino:arduino
4+
5+
test2.name=Test 2 Board
6+
test2.build.core=arduino:arduino
7+
test2.runtime.use_core_platform_path_for_runtime_platform_path=true

0 commit comments

Comments
 (0)