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
9a08fec5
Unverified
Commit
9a08fec5
authored
Apr 07, 2023
by
Cristian Maglie
Committed by
GitHub
Apr 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: library loading errors genereates unneeded compile failures (#2139)
parent
fe91ec6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
commands/instances.go
commands/instances.go
+3
-3
internal/integrationtest/compile_3/compile_test.go
internal/integrationtest/compile_3/compile_test.go
+26
-0
legacy/builder/libraries_loader.go
legacy/builder/libraries_loader.go
+4
-2
No files found.
commands/instances.go
View file @
9a08fec5
...
...
@@ -458,9 +458,9 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
}
}
for
_
,
err
:=
range
lm
.
RescanLibraries
()
{
s
:=
status
.
Newf
(
codes
.
FailedPrecondition
,
tr
(
"Loading libraries: %v"
),
err
)
responseError
(
s
)
for
_
,
status
:=
range
lm
.
RescanLibraries
()
{
logrus
.
WithError
(
status
.
Err
())
.
Warnf
(
"Error loading library"
)
// TODO: report as warning: responseError(err
)
}
// Refreshes the locale used, this will change the
...
...
internal/integrationtest/compile_3/compile_test.go
View file @
9a08fec5
...
...
@@ -16,6 +16,7 @@
package
compile_test
import
(
"fmt"
"testing"
"github.com/arduino/arduino-cli/internal/integrationtest"
...
...
@@ -154,3 +155,28 @@ func TestCompileRelativeLibraryPath(t *testing.T) {
require
.
Contains
(
t
,
string
(
stdout
),
"Used: "
+
FooLib
.
String
())
require
.
Contains
(
t
,
string
(
stdout
),
"Not used: "
+
cli
.
SketchbookDir
()
.
Join
(
"libraries"
,
"FooLib"
)
.
String
())
}
func
TestCompileWithInvalidLibrary
(
t
*
testing
.
T
)
{
env
,
cli
:=
integrationtest
.
CreateArduinoCLIWithEnvironment
(
t
)
defer
env
.
CleanUp
()
_
,
_
,
err
:=
cli
.
Run
(
"core"
,
"install"
,
"arduino:avr"
)
require
.
NoError
(
t
,
err
)
// Make an empty library
emptyLibPath
:=
cli
.
SketchbookDir
()
.
Join
(
"libraries"
,
"EmptyLib"
)
require
.
NoError
(
t
,
emptyLibPath
.
MkdirAll
())
// prepare sketch
sketch
,
err
:=
paths
.
New
(
"testdata"
,
"bare_minimum"
)
.
Abs
()
require
.
NoError
(
t
,
err
)
// Compile must succeed
_
,
_
,
err
=
cli
.
Run
(
"compile"
,
"-b"
,
"arduino:avr:uno"
,
sketch
.
String
())
require
.
NoError
(
t
,
err
)
// Verbose compile must report invalid library
_
,
stderr
,
err
:=
cli
.
Run
(
"compile"
,
"-v"
,
"-b"
,
"arduino:avr:uno"
,
sketch
.
String
())
require
.
NoError
(
t
,
err
)
require
.
Contains
(
t
,
string
(
stderr
),
fmt
.
Sprintf
(
"loading library from %s: invalid library: no header files found"
,
emptyLibPath
))
}
legacy/builder/libraries_loader.go
View file @
9a08fec5
...
...
@@ -56,14 +56,16 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
lm
.
AddLibrariesDir
(
folder
,
libraries
.
User
)
}
if
errs
:=
lm
.
RescanLibraries
();
len
(
errs
)
>
0
{
for
_
,
status
:=
range
lm
.
RescanLibraries
()
{
// With the refactoring of the initialization step of the CLI we changed how
// errors are returned when loading platforms and libraries, that meant returning a list of
// errors instead of a single one to enhance the experience for the user.
// I have no intention right now to start a refactoring of the legacy package too, so
// here's this shitty solution for now.
// When we're gonna refactor the legacy package this will be gone.
return
errors
.
WithStack
(
errs
[
0
]
.
Err
())
if
ctx
.
Verbose
{
ctx
.
Warn
(
status
.
Message
())
}
}
for
_
,
dir
:=
range
ctx
.
LibraryDirs
{
...
...
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