diff --git a/commands/bundle_tools_test.go b/commands/bundle_tools_test.go new file mode 100644 index 00000000000..f1ddec8735a --- /dev/null +++ b/commands/bundle_tools_test.go @@ -0,0 +1,57 @@ +// This file is part of arduino-cli. +// +// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package commands + +import ( + "fmt" + "testing" + + "github.com/arduino/arduino-cli/arduino/cores" + "github.com/arduino/arduino-cli/arduino/resources" + "github.com/arduino/go-paths-helper" + "github.com/stretchr/testify/require" + "go.bug.st/downloader/v2" +) + +func TestBundledToolsDownloadAvailability(t *testing.T) { + tmp, err := paths.MkTempDir("", "") + require.NoError(t, err) + defer tmp.RemoveAll() + + downloadAndTestChecksum := func(r *resources.DownloadResource) { + fmt.Println("Testing:", r.URL) + d, err := r.Download(tmp, &downloader.Config{}) + require.NoError(t, err) + err = d.Run() + require.NoError(t, err) + + checksum, err := r.TestLocalArchiveIntegrity(tmp) + require.True(t, checksum) + require.NoError(t, err) + } + + toTest := [][]*cores.Flavor{ + ctagsFlavors, + serialDiscoveryFlavors, + mdnsDiscoveryFlavors, + } + for _, flavors := range toTest { + for _, resource := range flavors { + downloadAndTestChecksum(resource.Resource) + resource.Resource.ArchivePath(tmp) + } + } +} diff --git a/commands/bundled_tools_ctags.go b/commands/bundled_tools_ctags.go index f37a835da41..5caf410849d 100644 --- a/commands/bundled_tools_ctags.go +++ b/commands/bundled_tools_ctags.go @@ -25,11 +25,9 @@ import ( var tr = i18n.Tr -func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease { - builtinPackage := pm.Packages.GetOrCreatePackage("builtin") - ctagsTool := builtinPackage.GetOrCreateTool("ctags") - ctagsRel := ctagsTool.GetOrCreateRelease(semver.ParseRelaxed("5.8-arduino11")) - ctagsRel.Flavors = []*cores.Flavor{ +var ( + ctagsVersion = semver.ParseRelaxed("5.8-arduino11") + ctagsFlavors = []*cores.Flavor{ { OS: "i686-pc-linux-gnu", Resource: &resources.DownloadResource{ @@ -91,5 +89,12 @@ func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease { }, }, } +) + +func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease { + builtinPackage := pm.Packages.GetOrCreatePackage("builtin") + ctagsTool := builtinPackage.GetOrCreateTool("ctags") + ctagsRel := ctagsTool.GetOrCreateRelease(ctagsVersion) + ctagsRel.Flavors = ctagsFlavors return ctagsRel }