diff --git a/commands/core/search.go b/commands/core/search.go index bb9a218de39..4cb28fdf1e8 100644 --- a/commands/core/search.go +++ b/commands/core/search.go @@ -48,7 +48,7 @@ func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc for _, targetPackage := range pm.Packages { for _, platform := range targetPackage.Platforms { // discard invalid platforms - if platform == nil || platform.Name == "" { + if platform == nil { continue } diff --git a/test/test_core.py b/test/test_core.py index e2813ddad62..9ede5e412ad 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -18,6 +18,7 @@ import simplejson as json import tempfile import hashlib +from git import Repo from pathlib import Path @@ -363,3 +364,24 @@ def test_core_update_with_local_url(run_command): res = run_command(f'core update-index --additional-urls="file://{test_index}"') assert res.ok assert "Updating index: test_index.json downloaded" in res.stdout + + +def test_core_search_list_manually_installed_cores(run_command, data_dir): + assert run_command("core update-index") + + # Verifies only cores in + res = run_command("core search --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 17 + + # Manually installs a core in sketchbooks hardware folder + git_url = "https://github.com/arduino/ArduinoCore-avr.git" + repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr") + assert Repo.clone_from(git_url, repo_dir) + + # Verifies manually installed core is correctly found + res = run_command("core search --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 18