From 7df8a490fbf63f4461409a8c46af6bc878e94406 Mon Sep 17 00:00:00 2001 From: Matteo Pologruto Date: Mon, 13 Feb 2023 17:26:41 +0100 Subject: [PATCH 1/2] Add instructions on how to contact the package manager to error message --- arduino/cores/packagemanager/download.go | 2 +- arduino/cores/packagemanager/install_uninstall.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arduino/cores/packagemanager/download.go b/arduino/cores/packagemanager/download.go index 619bfd436dc..ff69b8c659a 100644 --- a/arduino/cores/packagemanager/download.go +++ b/arduino/cores/packagemanager/download.go @@ -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, "") } diff --git a/arduino/cores/packagemanager/install_uninstall.go b/arduino/cores/packagemanager/install_uninstall.go index 87beee0a472..a2e23ae1cf1 100644 --- a/arduino/cores/packagemanager/install_uninstall.go +++ b/arduino/cores/packagemanager/install_uninstall.go @@ -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) } destDir := pme.PackagesDir.Join( toolRelease.Tool.Package.Name, From 11792ed60cd002a16b33434ad25ada9cf9e3e783 Mon Sep 17 00:00:00 2001 From: Matteo Pologruto Date: Wed, 15 Feb 2023 16:31:50 +0100 Subject: [PATCH 2/2] Add TestCoreBrokenDependency to core_test.go --- internal/integrationtest/core/core_test.go | 28 +++++++++++++--- .../integrationtest/testdata/test_index.json | 33 ++++++++++++++++++- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index 9bb8b95c092..a3408418009 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 @@ -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:x86@3.0.0", "--additional-urls="+url.String()) + require.Error(t, err) + require.Contains(t, string(stderr), "try contacting test@example.com") +} diff --git a/internal/integrationtest/testdata/test_index.json b/internal/integrationtest/testdata/test_index.json index 63f2672a2f0..70de2ac0fee 100644 --- a/internal/integrationtest/testdata/test_index.json +++ b/internal/integrationtest/testdata/test_index.json @@ -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": "test@example.com", "name": "test" },