Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
5efa9b5d
Unverified
Commit
5efa9b5d
authored
Oct 21, 2022
by
Silvano Cerza
Committed by
GitHub
Oct 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: `lib upgrade` command does not install new libraries dependencies (#1935)
parent
120b8525
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
17 deletions
+60
-17
commands/lib/upgrade.go
commands/lib/upgrade.go
+15
-17
internal/integrationtest/lib/lib_test.go
internal/integrationtest/lib/lib_test.go
+45
-0
No files found.
commands/lib/upgrade.go
View file @
5efa9b5d
...
...
@@ -17,11 +17,8 @@ package lib
import
(
"context"
"errors"
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/libraries"
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
"github.com/arduino/arduino-cli/commands"
rpc
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)
...
...
@@ -33,7 +30,7 @@ func LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, downloadCB rpc.Downloa
return
&
arduino
.
InvalidInstanceError
{}
}
if
err
:=
upgrade
(
lm
,
listLibraries
(
lm
,
true
,
false
),
downloadCB
,
taskCB
);
err
!=
nil
{
if
err
:=
upgrade
(
req
.
Instance
,
listLibraries
(
lm
,
true
,
false
),
downloadCB
,
taskCB
);
err
!=
nil
{
return
err
}
...
...
@@ -47,6 +44,9 @@ func LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, downloadCB rpc.Downloa
// LibraryUpgrade upgrades a library
func
LibraryUpgrade
(
ctx
context
.
Context
,
req
*
rpc
.
LibraryUpgradeRequest
,
downloadCB
rpc
.
DownloadProgressCB
,
taskCB
rpc
.
TaskProgressCB
)
error
{
lm
:=
commands
.
GetLibraryManager
(
req
)
if
lm
==
nil
{
return
&
arduino
.
InvalidInstanceError
{}
}
// Get the library to upgrade
name
:=
req
.
GetName
()
...
...
@@ -61,23 +61,21 @@ func LibraryUpgrade(ctx context.Context, req *rpc.LibraryUpgradeRequest, downloa
}
// Install update
return
upgrade
(
lm
,
[]
*
installedLib
{
lib
},
downloadCB
,
taskCB
)
return
upgrade
(
req
.
Instance
,
[]
*
installedLib
{
lib
},
downloadCB
,
taskCB
)
}
func
upgrade
(
lm
*
librariesmanager
.
LibrariesManager
,
libs
[]
*
installedLib
,
downloadCB
rpc
.
DownloadProgressCB
,
taskCB
rpc
.
TaskProgressCB
)
error
{
// Go through the list and download them
func
upgrade
(
instance
*
rpc
.
Instance
,
libs
[]
*
installedLib
,
downloadCB
rpc
.
DownloadProgressCB
,
taskCB
rpc
.
TaskProgressCB
)
error
{
for
_
,
lib
:=
range
libs
{
if
err
:=
downloadLibrary
(
lm
,
lib
.
Available
,
downloadCB
,
taskCB
);
err
!=
nil
{
return
err
libInstallReq
:=
&
rpc
.
LibraryInstallRequest
{
Instance
:
instance
,
Name
:
lib
.
Library
.
Name
,
Version
:
""
,
NoDeps
:
false
,
NoOverwrite
:
false
,
}
}
// Go through the list and install them
for
_
,
lib
:=
range
libs
{
if
err
:=
installLibrary
(
lm
,
lib
.
Available
,
libraries
.
User
,
taskCB
);
err
!=
nil
{
if
!
errors
.
Is
(
err
,
librariesmanager
.
ErrAlreadyInstalled
)
{
return
err
}
err
:=
LibraryInstall
(
context
.
Background
(),
libInstallReq
,
downloadCB
,
taskCB
)
if
err
!=
nil
{
return
err
}
}
...
...
internal/integrationtest/lib/lib_test.go
View file @
5efa9b5d
...
...
@@ -199,3 +199,48 @@ func TestLibDepsOutput(t *testing.T) {
require
.
Equal
(
t
,
"WiFiNINA"
,
jsonDeps
.
Dependencies
[
6
]
.
Name
)
require
.
Equal
(
t
,
jsonDeps
.
Dependencies
[
6
]
.
VersionInstalled
,
jsonDeps
.
Dependencies
[
6
]
.
VersionRequired
)
}
func
TestUpgradeLibraryWithDependencies
(
t
*
testing
.
T
)
{
env
,
cli
:=
integrationtest
.
CreateArduinoCLIWithEnvironment
(
t
)
defer
env
.
CleanUp
()
// Updates index for cores and libraries
_
,
_
,
err
:=
cli
.
Run
(
"core"
,
"update-index"
)
require
.
NoError
(
t
,
err
)
_
,
_
,
err
=
cli
.
Run
(
"lib"
,
"update-index"
)
require
.
NoError
(
t
,
err
)
// Install library
_
,
_
,
err
=
cli
.
Run
(
"lib"
,
"install"
,
"Arduino_ConnectionHandler@0.3.3"
)
require
.
NoError
(
t
,
err
)
stdOut
,
_
,
err
:=
cli
.
Run
(
"lib"
,
"deps"
,
"Arduino_ConnectionHandler@0.3.3"
,
"--format"
,
"json"
)
require
.
NoError
(
t
,
err
)
var
jsonDeps
struct
{
Dependencies
[]
struct
{
Name
string
`json:"name"`
VersionRequired
string
`json:"version_required"`
VersionInstalled
string
`json:"version_installed"`
}
`json:"dependencies"`
}
err
=
json
.
Unmarshal
(
stdOut
,
&
jsonDeps
)
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
jsonDeps
.
Dependencies
,
6
)
require
.
Equal
(
t
,
"Arduino_ConnectionHandler"
,
jsonDeps
.
Dependencies
[
0
]
.
Name
)
require
.
Equal
(
t
,
"Arduino_DebugUtils"
,
jsonDeps
.
Dependencies
[
1
]
.
Name
)
require
.
Equal
(
t
,
"MKRGSM"
,
jsonDeps
.
Dependencies
[
2
]
.
Name
)
require
.
Equal
(
t
,
"MKRNB"
,
jsonDeps
.
Dependencies
[
3
]
.
Name
)
require
.
Equal
(
t
,
"WiFi101"
,
jsonDeps
.
Dependencies
[
4
]
.
Name
)
require
.
Equal
(
t
,
"WiFiNINA"
,
jsonDeps
.
Dependencies
[
5
]
.
Name
)
// Test lib upgrade also install new dependencies of already installed library
_
,
_
,
err
=
cli
.
Run
(
"lib"
,
"upgrade"
,
"Arduino_ConnectionHandler"
)
require
.
NoError
(
t
,
err
)
stdOut
,
_
,
err
=
cli
.
Run
(
"lib"
,
"deps"
,
"Arduino_ConnectionHandler"
,
"--format"
,
"json"
)
require
.
NoError
(
t
,
err
)
jsonOut
:=
requirejson
.
Parse
(
t
,
stdOut
)
dependency
:=
jsonOut
.
Query
(
`.dependencies[] | select(.name=="MKRWAN")`
)
require
.
Equal
(
t
,
dependency
.
Query
(
".version_required"
),
dependency
.
Query
(
".version_installed"
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment