Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 357d465

Browse filesBrowse files
Include platform bundled libs when -b flag is used (#2000)
* Show bundled libs when `-b` flag is used * Modify test_lib.go to test the changes
1 parent 13fa409 commit 357d465
Copy full SHA for 357d465

File tree

Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed

‎commands/lib/list.go

Copy file name to clipboardExpand all lines: commands/lib/list.go
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ func LibraryList(ctx context.Context, req *rpc.LibraryListRequest) (*rpc.Library
4848

4949
nameFilter := strings.ToLower(req.GetName())
5050

51-
allLibs := listLibraries(lm, req.GetUpdatable(), req.GetAll())
51+
var allLibs []*installedLib
5252
if f := req.GetFqbn(); f != "" {
53+
allLibs = listLibraries(lm, req.GetUpdatable(), true)
5354
fqbn, err := cores.ParseFQBN(req.GetFqbn())
5455
if err != nil {
5556
return nil, &arduino.InvalidFQBNError{Cause: err}
@@ -93,6 +94,8 @@ func LibraryList(ctx context.Context, req *rpc.LibraryListRequest) (*rpc.Library
9394
for _, lib := range filteredRes {
9495
allLibs = append(allLibs, lib)
9596
}
97+
} else {
98+
allLibs = listLibraries(lm, req.GetUpdatable(), req.GetAll())
9699
}
97100

98101
installedLibs := []*rpc.InstalledLibrary{}

‎internal/integrationtest/lib/lib_test.go

Copy file name to clipboardExpand all lines: internal/integrationtest/lib/lib_test.go
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func TestListWithFqbn(t *testing.T) {
421421
require.NoError(t, err)
422422

423423
// Install core
424-
_, _, err = cli.Run("core", "install", "arduino:avr")
424+
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.6")
425425
require.NoError(t, err)
426426

427427
// Look at the plain text output
@@ -434,8 +434,12 @@ func TestListWithFqbn(t *testing.T) {
434434
stdout, stderr, err := cli.Run("lib", "list", "-b", "arduino:avr:uno")
435435
require.NoError(t, err)
436436
require.Empty(t, stderr)
437+
// Check if output contains bundled libraries
438+
require.Contains(t, string(stdout), "ArduinoJson")
439+
require.Contains(t, string(stdout), "EEPROM")
440+
require.Contains(t, string(stdout), "HID")
437441
lines := strings.Split(strings.TrimSpace(string(stdout)), "\n")
438-
require.Len(t, lines, 2)
442+
require.Len(t, lines, 7)
439443

440444
// Verifies library is compatible
441445
lines[1] = strings.Join(strings.Fields(lines[1]), " ")
@@ -447,11 +451,14 @@ func TestListWithFqbn(t *testing.T) {
447451
stdout, stderr, err = cli.Run("lib", "list", "-b", "arduino:avr:uno", "--format", "json")
448452
require.NoError(t, err)
449453
require.Empty(t, stderr)
450-
requirejson.Len(t, stdout, 1)
454+
requirejson.Len(t, stdout, 6)
451455

452456
// Verifies library is compatible
453-
requirejson.Query(t, stdout, `.[0] | .library | .name`, `"ArduinoJson"`)
454-
requirejson.Query(t, stdout, `.[0] | .library | .compatible_with | ."arduino:avr:uno"`, `true`)
457+
requirejson.Query(t, stdout, `sort_by(.library | .name) | .[0] | .library | .name`, `"ArduinoJson"`)
458+
requirejson.Query(t, stdout, `sort_by(.library | .name) | .[0] | .library | .compatible_with | ."arduino:avr:uno"`, `true`)
459+
460+
// Verifies bundled libs are shown if -b flag is used
461+
requirejson.Parse(t, stdout).Query(`.[] | .library | select(.container_platform=="arduino:avr@1.8.6")`).MustNotBeEmpty()
455462
}
456463

457464
func TestListProvidesIncludesFallback(t *testing.T) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.