Unverified Commit 736d1614 authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

[skip-changelog] Add remediation path when tool is not available for an OS (#2092)

* Add instructions on how to contact the package manager to error message

* Add TestCoreBrokenDependency to core_test.go
parent 5f733780
...@@ -125,7 +125,7 @@ func (pme *Explorer) DownloadToolRelease(tool *cores.ToolRelease, config *downlo ...@@ -125,7 +125,7 @@ func (pme *Explorer) DownloadToolRelease(tool *cores.ToolRelease, config *downlo
if resource == nil { if resource == nil {
return &arduino.FailedDownloadError{ return &arduino.FailedDownloadError{
Message: tr("Error downloading tool %s", tool), Message: tr("Error downloading tool %s", tool),
Cause: errors.New(tr("no versions available for the current OS"))} Cause: errors.New(tr("no versions available for the current OS, try contacting %s", tool.Tool.Package.Email))}
} }
return resource.Download(pme.DownloadDir, config, tool.String(), progressCB, "") return resource.Download(pme.DownloadDir, config, tool.String(), progressCB, "")
} }
......
...@@ -313,7 +313,8 @@ func (pme *Explorer) InstallTool(toolRelease *cores.ToolRelease, taskCB rpc.Task ...@@ -313,7 +313,8 @@ func (pme *Explorer) InstallTool(toolRelease *cores.ToolRelease, taskCB rpc.Task
toolResource := toolRelease.GetCompatibleFlavour() toolResource := toolRelease.GetCompatibleFlavour()
if toolResource == nil { if toolResource == nil {
return fmt.Errorf(tr("no compatible version of %s tools found for the current os"), toolRelease.Tool.Name) return fmt.Errorf(tr("no compatible version of %s tools found for the current os, try contacting %s"),
toolRelease.Tool.Name, toolRelease.Tool.Package.Email)
} }
destDir := pme.PackagesDir.Join( destDir := pme.PackagesDir.Join(
toolRelease.Tool.Package.Name, toolRelease.Tool.Package.Name,
......
...@@ -80,7 +80,7 @@ func TestCoreSearch(t *testing.T) { ...@@ -80,7 +80,7 @@ func TestCoreSearch(t *testing.T) {
// show all versions // show all versions
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String()) out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err) require.NoError(t, err)
requirejson.Len(t, out, 2) requirejson.Len(t, out, 3)
checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) { checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version) jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
...@@ -150,7 +150,7 @@ func TestCoreSearchNoArgs(t *testing.T) { ...@@ -150,7 +150,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
// update custom index and install test core (installed cores affect `core search`) // update custom index and install test core (installed cores affect `core search`)
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String()) _, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
require.NoError(t, err) require.NoError(t, err)
_, _, err = cli.Run("core", "install", "test:x86", "--additional-urls="+url.String()) _, _, err = cli.Run("core", "install", "test:x86@2.0.0", "--additional-urls="+url.String())
require.NoError(t, err) require.NoError(t, err)
// list all with no additional urls, ensure the test core won't show up // list all with no additional urls, ensure the test core won't show up
...@@ -161,7 +161,7 @@ func TestCoreSearchNoArgs(t *testing.T) { ...@@ -161,7 +161,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
lines = append(lines, strings.Fields(strings.TrimSpace(v))) lines = append(lines, strings.Fields(strings.TrimSpace(v)))
} }
// The header is printed on the first lines // The header is printed on the first lines
require.Equal(t, []string{"test:x86", "2.0.0", "test_core"}, lines[20]) require.Equal(t, []string{"test:x86", "2.0.0", "test_core"}, lines[21])
numPlatforms := len(lines) - 1 numPlatforms := len(lines) - 1
// same thing in JSON format, also check the number of platforms found is the same // same thing in JSON format, also check the number of platforms found is the same
...@@ -178,7 +178,7 @@ func TestCoreSearchNoArgs(t *testing.T) { ...@@ -178,7 +178,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
lines = append(lines, strings.Fields(strings.TrimSpace(v))) lines = append(lines, strings.Fields(strings.TrimSpace(v)))
} }
// The header is printed on the first lines // The header is printed on the first lines
require.Equal(t, []string{"test:x86", "2.0.0", "test_core"}, lines[21]) require.Equal(t, []string{"test:x86", "3.0.0", "test_core"}, lines[22])
numPlatforms = len(lines) - 1 numPlatforms = len(lines) - 1
// same thing in JSON format, also check the number of platforms found is the same // same thing in JSON format, also check the number of platforms found is the same
...@@ -725,7 +725,7 @@ func TestCoreListSortedResults(t *testing.T) { ...@@ -725,7 +725,7 @@ func TestCoreListSortedResults(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// install some core for testing // install some core for testing
_, _, err = cli.Run("core", "install", "test:x86", "Retrokits-RK002:arm", "Package:x86", "--additional-urls="+url.String()) _, _, err = cli.Run("core", "install", "test:x86@2.0.0", "Retrokits-RK002:arm", "Package:x86", "--additional-urls="+url.String())
require.NoError(t, err) require.NoError(t, err)
// list all with additional url specified // list all with additional url specified
...@@ -1006,3 +1006,21 @@ func TestCoreInstallRunsToolPostInstallScript(t *testing.T) { ...@@ -1006,3 +1006,21 @@ func TestCoreInstallRunsToolPostInstallScript(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Contains(t, string(stdout), "Skipping tool configuration.") require.Contains(t, string(stdout), "Skipping tool configuration.")
} }
func TestCoreBrokenDependency(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()
// Set up an http server to serve our custom index file
test_index := paths.New("..", "testdata", "test_index.json")
url := env.HTTPServeFile(8000, test_index)
// Run update-index with our test index
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
require.NoError(t, err)
// Check that the download fails and the correct message is displayed
_, stderr, err := cli.Run("core", "install", "test:x86@3.0.0", "--additional-urls="+url.String())
require.Error(t, err)
require.Contains(t, string(stderr), "try contacting test@example.com")
}
...@@ -44,9 +44,40 @@ ...@@ -44,9 +44,40 @@
"name": "Test Board" "name": "Test Board"
} }
] ]
},
{
"category": "Test Category",
"help": {
"online": "https://github.com/Arduino/arduino-cli"
},
"url": "https://raw.githubusercontent.com/arduino/arduino-cli/master/internal/integrationtest/testdata/core.zip",
"checksum": "SHA-256:6a338cf4d6d501176a2d352c87a8d72ac7488b8c5b82cdf2a4e2cef630391092",
"name": "test_core",
"version": "3.0.0",
"architecture": "x86",
"archiveFileName": "core.zip",
"size": "486",
"toolsDependencies": [
{
"packager": "test",
"version": "1.0.6",
"name": "rp2040tools"
}
],
"boards": [
{
"name": "Test Board"
}
]
}
],
"tools": [
{
"name": "rp2040tools",
"version": "1.0.6",
"systems": []
} }
], ],
"tools": [],
"email": "test@example.com", "email": "test@example.com",
"name": "test" "name": "test"
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment