Skip to content

Increase priority of manually-installed platform. #2810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed integration test
  • Loading branch information
cmaglie committed Feb 4, 2025
commit dad506358782e1c200e35eae84f1da2dfdce01a5
4 changes: 2 additions & 2 deletions internal/integrationtest/board/board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ func TestBoardListallWithManuallyInstalledPlatform(t *testing.T) {
"platform": {
"metadata": {
"id": "arduino-beta-development:samd",
"manually_installed": true
},
"release": {
"installed": true,
"version": "1.8.11",
"name": "Arduino SAMD (32-bits ARM Cortex-M0+) Boards"
},
}
Expand All @@ -251,10 +251,10 @@ func TestBoardListallWithManuallyInstalledPlatform(t *testing.T) {
"platform": {
"metadata": {
"id": "arduino-beta-development:samd",
"manually_installed": true
},
"release": {
"installed": true,
"version": "1.8.11",
"name": "Arduino SAMD (32-bits ARM Cortex-M0+) Boards"
},
}
Expand Down
6 changes: 3 additions & 3 deletions internal/integrationtest/board/hardware_loading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ func TestHardwareLoading(t *testing.T) {
"platforms": [
{
"id": "my_avr_platform:avr",
"installed_version": "9.9.9",
"installed_version": "",
"releases": {
"9.9.9": {
"": {
"name": "My AVR Boards",
"boards": [
{
Expand All @@ -207,7 +207,7 @@ func TestHardwareLoading(t *testing.T) {
"id": "my_symlinked_avr_platform:avr",
"manually_installed": true,
"releases": {
"9.9.9": {
"": {
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/integrationtest/compile_4/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ type buildOptions struct {
Verbose bool
}

func tryBuild(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI, fqbn string, optionsArg ...*buildOptions) (*builderOutput, error) {
func tryBuild(t *testing.T, _ *integrationtest.Environment, cli *integrationtest.ArduinoCLI, fqbn string, optionsArg ...*buildOptions) (*builderOutput, error) {
var options *buildOptions
if len(optionsArg) == 0 {
options = &buildOptions{}
Expand Down Expand Up @@ -870,7 +870,7 @@ func tryBuild(t *testing.T, env *integrationtest.Environment, cli *integrationte
return &out, err
}

func tryPreprocess(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI, fqbn string) (*paths.Path, []byte, error) {
func tryPreprocess(t *testing.T, _ *integrationtest.Environment, cli *integrationtest.ArduinoCLI, fqbn string) (*paths.Path, []byte, error) {
subTestName := strings.Split(t.Name(), "/")[1]
sketchPath, err := paths.New("testdata", subTestName).Abs()
require.NoError(t, err)
Expand Down
108 changes: 40 additions & 68 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"runtime"
"sort"
"strconv"
Expand Down Expand Up @@ -52,12 +51,16 @@ func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) {
"platforms": [
{
"id":"DxCore-dev:megaavr",
"manually_installed": true,
"installed_version":"1.4.10",
"releases": {
"1.4.10": {
"": {
"name":"DxCore"
}
}
},
"installed_version": "",
"latest_version": "",
"has_manually_installed_release": true
}
]
}`)
Expand Down Expand Up @@ -512,63 +515,9 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) {
requirejson.Contains(t, stdout, `{"platforms":[
{
"id": "arduino-beta-development:avr",
"latest_version": "1.8.3",
"latest_version": "",
"releases": {
"1.8.3": {
"name": "Arduino AVR Boards"
}
}
}
]}`)
}

func TestCoreListShowsLatestVersionWhenMultipleReleasesOfAManuallyInstalledCoreArePresent(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

_, _, err := cli.Run("core", "update-index")
require.NoError(t, err)

// Verifies only cores in board manager are shown
stdout, _, err := cli.Run("core", "list", "--all", "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.platforms | length > 0`, `true`)
length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".platforms | length").String())
require.NoError(t, err)

// Manually installs a core in sketchbooks hardware folder
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
_, err = git.PlainClone(filepath.Join(repoDir.String(), "1.8.3"), false, &git.CloneOptions{
URL: gitUrl,
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
})
require.NoError(t, err)

tmp := paths.New(t.TempDir(), "1.8.4")
_, err = git.PlainClone(tmp.String(), false, &git.CloneOptions{
URL: gitUrl,
ReferenceName: plumbing.NewTagReferenceName("1.8.4"),
})
require.NoError(t, err)

err = tmp.Rename(repoDir.Join("1.8.4"))
require.NoError(t, err)

// When manually installing 2 releases of the same core, the newest one takes precedence
stdout, _, err = cli.Run("core", "list", "--all", "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.platforms | length`, fmt.Sprint(length+1))
requirejson.Contains(t, stdout, `{"platforms":[
{
"id": "arduino-beta-development:avr",
"latest_version": "1.8.4",
"installed_version": "1.8.4",
"releases": {
"1.8.3": {
"name": "Arduino AVR Boards"
},
"1.8.3": {
"": {
"name": "Arduino AVR Boards"
}
}
Expand Down Expand Up @@ -606,12 +555,15 @@ func TestCoreListUpdatableAllFlags(t *testing.T) {
requirejson.Contains(t, stdout, `{"platforms":[
{
"id": "arduino-beta-development:avr",
"latest_version": "1.8.3",
"manually_installed": true,
"installed_version": "",
"latest_version": "",
"releases": {
"1.8.3": {
"": {
"name": "Arduino AVR Boards"
}
}
},
"has_manually_installed_release": true
}
]}`)
}
Expand Down Expand Up @@ -1009,7 +961,7 @@ func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) {
{
"id": "arduino-beta-dev:platform_with_missing_custom_board_options",
"releases": {
"4.2.0": {
"": {
"boards": [
{
"fqbn": "arduino-beta-dev:platform_with_missing_custom_board_options:nessuno"
Expand Down Expand Up @@ -1396,10 +1348,10 @@ func TestCoreOverrideIfInstalledInSketchbook(t *testing.T) {
require.NoError(t, err)

// Copy it in the sketchbook hardware folder (simulate a user installed core)
// avrCore := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.5")
// avrCoreCopy := cli.SketchbookDir().Join("hardware", "arduino", "avr")
// require.NoError(t, avrCoreCopy.Parent().MkdirAll())
// require.NoError(t, avrCore.CopyDirTo(avrCoreCopy))
avrCore := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.5")
avrCoreCopy := cli.SketchbookDir().Join("hardware", "arduino", "avr")
require.NoError(t, avrCoreCopy.Parent().MkdirAll())
require.NoError(t, avrCore.CopyDirTo(avrCoreCopy))

// Install avr@1.8.6
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.6")
Expand All @@ -1408,5 +1360,25 @@ func TestCoreOverrideIfInstalledInSketchbook(t *testing.T) {
// List cores and check that version 1.8.5 is listed
stdout, _, err := cli.Run("core", "list", "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.platforms.[] | select(.id=="arduino:avr") | .installed_version`, `"1.8.5"`)
requirejson.Contains(t, stdout, `{
"platforms": [
{
"id": "arduino:avr",
"indexed": true,
"releases" : {
"": {
"name": "Arduino AVR Boards",
"installed": true
},
"1.8.6": {
"name": "Arduino AVR Boards",
"installed": true
}
},
"installed_version": "1.8.6",
"latest_version": "1.8.6",
"has_manually_installed_release": true
}
]
}`)
}
Empty file.