-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added library dependency support (#351)
* Added infrastructure to handle 'dependency' field in library index * Added globals.ParseLibraryReferenceArgs method * Added check for missing library version/name in args * Added check for missing core/arch/version in core arg parsing * 100% test coverage for librariesindexer module * Added grpc call LibraryResolveDependencies (WIP) This is just the body of the call, no implementation yet. * Use semver.Dependency interface to represent a library dependency * Added library-dep resolution function in core modules * Added implementation for LibraryResolveDependency grpc call * Implementation of deps install in 'lib install' command * Added no-deps flag in lib install command * Added lib deps command
- Loading branch information
Showing
26 changed files
with
205,163 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* This file is part of arduino-cli. | ||
* | ||
* Copyright 2018 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 [email protected]. | ||
*/ | ||
|
||
package librariesindex | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/arduino/arduino-cli/arduino/libraries" | ||
"github.com/arduino/go-paths-helper" | ||
"github.com/stretchr/testify/require" | ||
semver "go.bug.st/relaxed-semver" | ||
) | ||
|
||
func TestIndexer(t *testing.T) { | ||
fail1, err := LoadIndex(paths.New("testdata/inexistent")) | ||
require.Error(t, err) | ||
require.Nil(t, fail1) | ||
|
||
fail2, err := LoadIndex(paths.New("testdata/invalid.json")) | ||
require.Error(t, err) | ||
require.Nil(t, fail2) | ||
|
||
index, err := LoadIndex(paths.New("testdata/library_index.json")) | ||
require.NoError(t, err) | ||
require.Equal(t, 2380, len(index.Libraries), "parsed libraries count") | ||
|
||
alp := index.Libraries["Arduino Low Power"] | ||
require.NotNil(t, alp) | ||
require.Equal(t, 4, len(alp.Releases)) | ||
require.Equal(t, "Arduino Low [email protected]", alp.Latest.String()) | ||
require.Len(t, alp.Latest.Dependencies, 1) | ||
require.Equal(t, "RTCZero", alp.Latest.Dependencies[0].GetName()) | ||
require.Equal(t, "", alp.Latest.Dependencies[0].GetConstraint().String()) | ||
require.Equal(t, "[1.0.0 1.1.0 1.2.0 1.2.1]", fmt.Sprintf("%v", alp.Versions())) | ||
|
||
rtc100ref := &Reference{Name: "RTCZero", Version: semver.MustParse("1.0.0")} | ||
require.Equal(t, "[email protected]", rtc100ref.String()) | ||
rtc100 := index.FindRelease(rtc100ref) | ||
require.NotNil(t, rtc100) | ||
require.Equal(t, "[email protected]", rtc100.String()) | ||
|
||
rtcLatestRef := &Reference{Name: "RTCZero"} | ||
require.Equal(t, "RTCZero", rtcLatestRef.String()) | ||
rtcLatest := index.FindRelease(rtcLatestRef) | ||
require.NotNil(t, rtcLatest) | ||
require.Equal(t, "[email protected]", rtcLatest.String()) | ||
|
||
rtcInexistent := index.FindRelease(&Reference{ | ||
Name: "RTCZero", | ||
Version: semver.MustParse("0.0.0-blah"), | ||
}) | ||
require.Nil(t, rtcInexistent) | ||
|
||
rtcInexistent = index.FindRelease(&Reference{ | ||
Name: "RTCZero-blah", | ||
}) | ||
require.Nil(t, rtcInexistent) | ||
|
||
rtc := index.FindIndexedLibrary(&libraries.Library{Name: "RTCZero"}) | ||
require.NotNil(t, rtc) | ||
require.Equal(t, "RTCZero", rtc.Name) | ||
|
||
rtcUpdate := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero", Version: semver.MustParse("1.0.0")}) | ||
require.NotNil(t, rtcUpdate) | ||
require.Equal(t, "[email protected]", rtcUpdate.String()) | ||
|
||
rtcNoUpdate := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero", Version: semver.MustParse("3.0.0")}) | ||
require.Nil(t, rtcNoUpdate) | ||
|
||
rtcInexistent2 := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero-blah", Version: semver.MustParse("1.0.0")}) | ||
require.Nil(t, rtcInexistent2) | ||
|
||
resolve1 := index.ResolveDependencies(alp.Releases["1.2.1"]) | ||
require.Len(t, resolve1, 2) | ||
require.Contains(t, resolve1, alp.Releases["1.2.1"]) | ||
require.Contains(t, resolve1, rtc.Releases["1.6.0"]) | ||
|
||
oauth010 := index.FindRelease(&Reference{Name: "Arduino_OAuth", Version: semver.MustParse("0.1.0")}) | ||
require.NotNil(t, oauth010) | ||
require.Equal(t, "[email protected]", oauth010.String()) | ||
eccx133 := index.FindRelease(&Reference{Name: "ArduinoECCX08", Version: semver.MustParse("1.3.3")}) | ||
require.NotNil(t, eccx133) | ||
require.Equal(t, "[email protected]", eccx133.String()) | ||
bear130 := index.FindRelease(&Reference{Name: "ArduinoBearSSL", Version: semver.MustParse("1.3.0")}) | ||
require.NotNil(t, bear130) | ||
require.Equal(t, "[email protected]", bear130.String()) | ||
http040 := index.FindRelease(&Reference{Name: "ArduinoHttpClient", Version: semver.MustParse("0.4.0")}) | ||
require.NotNil(t, http040) | ||
require.Equal(t, "[email protected]", http040.String()) | ||
|
||
resolve2 := index.ResolveDependencies(oauth010) | ||
require.Len(t, resolve2, 4) | ||
require.Contains(t, resolve2, oauth010) | ||
require.Contains(t, resolve2, eccx133) | ||
require.Contains(t, resolve2, bear130) | ||
require.Contains(t, resolve2, http040) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "invalid", |
Oops, something went wrong.