Skip to content

Improved package index merging logic #2713

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

Merged
merged 2 commits into from
Oct 7, 2024
Merged
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
Next Next commit
Added tests
  • Loading branch information
cmaglie committed Oct 1, 2024
commit 24e152a20cde638bac86d6945bb7e2be76d399a5
46 changes: 46 additions & 0 deletions internal/arduino/cores/packagemanager/package_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,52 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
require.Equal(t, bossac18.InstallDir.String(), uploadProperties.Get("runtime.tools.bossac.path"))
}

func TestIndexMerger(t *testing.T) {
t.Setenv("ARDUINO_DATA_DIR", dataDir1.String())
pmb := NewBuilder(
dataDir1,
dataDir1.Join("packages"),
nil,
dataDir1.Join("staging"),
dataDir1,
"test",
downloader.GetDefaultConfig(),
)

loadIndex := func(addr string) {
res, err := url.Parse(addr)
require.NoError(t, err)
require.NoError(t, pmb.LoadPackageIndex(res))
}
loadIndex("https://test.com/package_with_regular_dfu_util_index.json") // this is not downloaded, it just picks the "local cached" file package_test_index.json
loadIndex("https://test.com/package_with_empty_dfu_util_index.json") // this is not downloaded, it just picks the "local cached" file package_test_index.json

// We ignore the errors returned since they might not be necessarily blocking
// but just warnings for the user, like in the case a board is not loaded
// because of malformed menus
pmb.LoadHardware()
pm := pmb.Build()
pme, release := pm.NewExplorer()
defer release()

dfu_util := pme.GetTool("arduino:dfu-util")
require.NotNil(t, dfu_util)
dfu_release := dfu_util.GetOrCreateRelease(semver.ParseRelaxed("0.11.0-arduino5"))
require.NotNil(t, dfu_release)
require.Len(t, dfu_release.Flavors, 6)

test_tool := pme.GetTool("arduino:test-tool")
require.NotNil(t, test_tool)
test_tool_release := test_tool.GetOrCreateRelease(semver.ParseRelaxed("1.0.0"))
require.NotNil(t, test_tool_release)
// Check that the new entry has been added
require.Len(t, test_tool_release.Flavors, 2)
require.Equal(t, test_tool_release.Flavors[1].OS, "arm-linux-gnueabihf")
require.Equal(t, test_tool_release.Flavors[1].Resource.URL, "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_arm.tar.gz")
// Check that the invalid entry did not replace existing one
require.NotEqual(t, test_tool_release.Flavors[0].Resource.URL, "INVALID")
}

func TestIdentifyBoard(t *testing.T) {
pmb := NewBuilder(customHardware, customHardware, nil, customHardware, customHardware, "test", downloader.GetDefaultConfig())
pmb.LoadHardwareFromDirectory(customHardware)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"packages": [
{
"name": "arduino",
"maintainer": "Arduino",
"websiteURL": "http://www.arduino.cc/",
"email": "packages@arduino.cc",
"help": {
"online": "http://www.arduino.cc/en/Reference/HomePage"
},
"platforms": [],
"tools": [
{
"name": "test-tool",
"version": "1.0.0",
"systems": [
{
"host": "i386-apple-darwin11",
"url": "INVALID",
"archiveFileName": "INVALID",
"size": "100",
"checksum": "SHA-256:9e576c6e44f54b1e921a43ea77bcc08ec99e0e4e0905f4b9acf9ab2c979f0a22"
},
{
"host": "arm-linux-gnueabihf",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_arm.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-linux_arm.tar.gz",
"size": "2512819",
"checksum": "SHA-256:acd4bd283fd408515279a44dd830499ad37b0767e8f2fde5c27e878ded909dc3"
}
]
},
{
"name": "dfu-util",
"version": "0.11.0-arduino5",
"systems": []
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"packages": [
{
"name": "arduino",
"maintainer": "Arduino",
"websiteURL": "http://www.arduino.cc/",
"email": "packages@arduino.cc",
"help": {
"online": "http://www.arduino.cc/en/Reference/HomePage"
},
"platforms": [],
"tools": [
{
"name": "test-tool",
"version": "1.0.0",
"systems": [
{
"host": "i386-apple-darwin11",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-darwin_amd64.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-darwin_amd64.tar.gz",
"size": "72429",
"checksum": "SHA-256:9e576c6e44f54b1e921a43ea77bcc08ec99e0e4e0905f4b9acf9ab2c979f0a22"
}
]
},
{
"name": "dfu-util",
"version": "0.11.0-arduino5",
"systems": [
{
"host": "i386-apple-darwin11",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-darwin_amd64.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-darwin_amd64.tar.gz",
"size": "72429",
"checksum": "SHA-256:9e576c6e44f54b1e921a43ea77bcc08ec99e0e4e0905f4b9acf9ab2c979f0a22"
},
{
"host": "arm-linux-gnueabihf",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_arm.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-linux_arm.tar.gz",
"size": "2512819",
"checksum": "SHA-256:acd4bd283fd408515279a44dd830499ad37b0767e8f2fde5c27e878ded909dc3"
},
{
"host": "aarch64-linux-gnu",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_arm64.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-linux_arm64.tar.gz",
"size": "2607592",
"checksum": "SHA-256:b3f46a65da0c2fed2449dc5a3351c3c74953a868aa7f8d99ba2bb8c418344fe9"
},
{
"host": "x86_64-linux-gnu",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_amd64.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-linux_amd64.tar.gz",
"size": "2283425",
"checksum": "SHA-256:96c64c278561af806b585c123c85748926ad02b1aedc07e5578ca9bee2be0d2a"
},
{
"host": "i686-linux-gnu",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-linux_386.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-linux_386.tar.gz",
"size": "2524406",
"checksum": "SHA-256:9a707692261e5710ed79a6d8a4031ffd0bfe1e585216569934346e9b2d68d0c2"
},
{
"host": "i686-mingw32",
"url": "http://downloads.arduino.cc/tools/dfu-util-0.11-arduino5-windows_386.tar.gz",
"archiveFileName": "dfu-util-0.11-arduino5-windows_386.tar.gz",
"size": "571340",
"checksum": "SHA-256:6451e16bf77600fe2436c8708ab4b75077c49997cf8bedf03221d9d6726bb641"
}
]
}
]
}
]
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy