Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Jul 26, 2024
1 parent 8522850 commit 7a5cf9d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
41 changes: 41 additions & 0 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,3 +1303,44 @@ 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:[email protected]")
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()

// 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(`"build.board.platform.path=` + boardPlatformPath + `"`)
out.ArrayMustContain(`"build.core.platform.path=` + corePlatformPath + `"`)
out.ArrayMustContain(`"build.core.path=` + corePath + `"`)
out.ArrayMustContain(`"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(`"build.board.platform.path=` + boardPlatformPath + `"`)
out.ArrayMustContain(`"build.core.platform.path=` + corePlatformPath + `"`)
out.ArrayMustContain(`"build.core.path=` + corePath + `"`)
// https://github.com/arduino/arduino-cli/issues/2616
out.ArrayMustContain(`"runtime.platform.path=` + corePlatformPath + `"`)
}
}
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7a5cf9d

Please sign in to comment.