Skip to content

Commit fb8931c

Browse files
authored
[skip-changelog] Added tests to check for bundled tools availability (#1489)
1 parent 4c5ebc5 commit fb8931c

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

Diff for: commands/bundle_tools_test.go

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2021 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package commands
17+
18+
import (
19+
"fmt"
20+
"testing"
21+
22+
"github.com/arduino/arduino-cli/arduino/cores"
23+
"github.com/arduino/arduino-cli/arduino/resources"
24+
"github.com/arduino/go-paths-helper"
25+
"github.com/stretchr/testify/require"
26+
"go.bug.st/downloader/v2"
27+
)
28+
29+
func TestBundledToolsDownloadAvailability(t *testing.T) {
30+
tmp, err := paths.MkTempDir("", "")
31+
require.NoError(t, err)
32+
defer tmp.RemoveAll()
33+
34+
downloadAndTestChecksum := func(r *resources.DownloadResource) {
35+
fmt.Println("Testing:", r.URL)
36+
d, err := r.Download(tmp, &downloader.Config{})
37+
require.NoError(t, err)
38+
err = d.Run()
39+
require.NoError(t, err)
40+
41+
checksum, err := r.TestLocalArchiveIntegrity(tmp)
42+
require.True(t, checksum)
43+
require.NoError(t, err)
44+
}
45+
46+
toTest := [][]*cores.Flavor{
47+
ctagsFlavors,
48+
serialDiscoveryFlavors,
49+
mdnsDiscoveryFlavors,
50+
}
51+
for _, flavors := range toTest {
52+
for _, resource := range flavors {
53+
downloadAndTestChecksum(resource.Resource)
54+
resource.Resource.ArchivePath(tmp)
55+
}
56+
}
57+
}

Diff for: commands/bundled_tools_ctags.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ import (
2525

2626
var tr = i18n.Tr
2727

28-
func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease {
29-
builtinPackage := pm.Packages.GetOrCreatePackage("builtin")
30-
ctagsTool := builtinPackage.GetOrCreateTool("ctags")
31-
ctagsRel := ctagsTool.GetOrCreateRelease(semver.ParseRelaxed("5.8-arduino11"))
32-
ctagsRel.Flavors = []*cores.Flavor{
28+
var (
29+
ctagsVersion = semver.ParseRelaxed("5.8-arduino11")
30+
ctagsFlavors = []*cores.Flavor{
3331
{
3432
OS: "i686-pc-linux-gnu",
3533
Resource: &resources.DownloadResource{
@@ -91,5 +89,12 @@ func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease {
9189
},
9290
},
9391
}
92+
)
93+
94+
func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease {
95+
builtinPackage := pm.Packages.GetOrCreatePackage("builtin")
96+
ctagsTool := builtinPackage.GetOrCreateTool("ctags")
97+
ctagsRel := ctagsTool.GetOrCreateRelease(ctagsVersion)
98+
ctagsRel.Flavors = ctagsFlavors
9499
return ctagsRel
95100
}

0 commit comments

Comments
 (0)