Skip to content

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

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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion arduino/cores/packagemanager/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (pme *Explorer) DownloadToolRelease(tool *cores.ToolRelease, config *downlo
if resource == nil {
return &arduino.FailedDownloadError{
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, "")
}
Expand Down
3 changes: 2 additions & 1 deletion arduino/cores/packagemanager/install_uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ func (pme *Explorer) InstallTool(toolRelease *cores.ToolRelease, taskCB rpc.Task

toolResource := toolRelease.GetCompatibleFlavour()
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)
Comment on lines +316 to +317
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string can not be correctly translated, you must replace unindexed %s with %[1]s and %[2]s.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified here: #2099

}
destDir := pme.PackagesDir.Join(
toolRelease.Tool.Package.Name,
Expand Down
28 changes: 23 additions & 5 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestCoreSearch(t *testing.T) {
// show all versions
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
requirejson.Len(t, out, 2)
requirejson.Len(t, out, 3)

checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
// update custom index and install test core (installed cores affect `core search`)
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
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)

// list all with no additional urls, ensure the test core won't show up
Expand All @@ -161,7 +161,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
lines = append(lines, strings.Fields(strings.TrimSpace(v)))
}
// 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

// same thing in JSON format, also check the number of platforms found is the same
Expand All @@ -178,7 +178,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
lines = append(lines, strings.Fields(strings.TrimSpace(v)))
}
// 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

// same thing in JSON format, also check the number of platforms found is the same
Expand Down Expand Up @@ -725,7 +725,7 @@ func TestCoreListSortedResults(t *testing.T) {
require.NoError(t, err)

// 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)

// list all with additional url specified
Expand Down Expand Up @@ -1006,3 +1006,21 @@ func TestCoreInstallRunsToolPostInstallScript(t *testing.T) {
require.NoError(t, err)
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:[email protected]", "--additional-urls="+url.String())
require.Error(t, err)
require.Contains(t, string(stderr), "try contacting [email protected]")
}
33 changes: 32 additions & 1 deletion internal/integrationtest/testdata/test_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,40 @@
"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": "[email protected]",
"name": "test"
},
Expand Down