Skip to content

Commit 13f5203

Browse files
authoredFeb 12, 2021
Add --all flag to core list command and gRPC interface (#1166)
Setting that flags return all installed and installable platforms, including installed manually by the user in their Sketchbook hardware folder.
1 parent 560025a commit 13f5203

File tree

12 files changed

+371
-81
lines changed

12 files changed

+371
-81
lines changed
 

‎arduino/cores/cores.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ import (
2828

2929
// Platform represents a platform package.
3030
type Platform struct {
31-
Architecture string // The name of the architecture of this package.
32-
Name string
33-
Category string
34-
Releases map[string]*PlatformRelease // The Releases of this platform, labeled by version.
35-
Package *Package `json:"-"`
31+
Architecture string // The name of the architecture of this package.
32+
Name string
33+
Category string
34+
Releases map[string]*PlatformRelease // The Releases of this platform, labeled by version.
35+
Package *Package `json:"-"`
36+
ManuallyInstalled bool // true if the Platform has been installed without the CLI
3637
}
3738

3839
// PlatformReleaseHelp represents the help URL for this Platform release

‎arduino/cores/packagemanager/loader.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,15 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
166166
return fmt.Errorf("looking for boards.txt in %s: %s", possibleBoardTxtPath, err)
167167

168168
} else if exist {
169-
170-
// case: ARCHITECTURE/boards.txt
171-
// this is the general case for unversioned Platform
172-
version := semver.MustParse("")
173-
174-
// FIXME: this check is duplicated, find a better way to handle this
175-
if exist, err := platformPath.Join("boards.txt").ExistCheck(); err != nil {
176-
return fmt.Errorf("opening boards.txt: %s", err)
177-
} else if !exist {
178-
continue
169+
platformTxtPath := platformPath.Join("platform.txt")
170+
platformProperties, err := properties.SafeLoad(platformTxtPath.String())
171+
if err != nil {
172+
return fmt.Errorf("loading platform.txt: %w", err)
179173
}
180174

175+
platformName := platformProperties.Get("name")
176+
version := semver.MustParse(platformProperties.Get("version"))
177+
181178
// check if package_bundled_index.json exists
182179
isIDEBundled := false
183180
packageBundledIndexPath := packageDir.Parent().Join("package_index_bundled.json")
@@ -210,6 +207,12 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
210207
}
211208

212209
platform := targetPackage.GetOrCreatePlatform(architecture)
210+
if platform.Name == "" {
211+
platform.Name = platformName
212+
}
213+
if !isIDEBundled {
214+
platform.ManuallyInstalled = true
215+
}
213216
release := platform.GetOrCreateRelease(version)
214217
release.IsIDEBundled = isIDEBundled
215218
if isIDEBundled {

‎cli/core/list.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ func initListCommand() *cobra.Command {
3939
Run: runListCommand,
4040
}
4141
listCommand.Flags().BoolVar(&listFlags.updatableOnly, "updatable", false, "List updatable platforms.")
42+
listCommand.Flags().BoolVar(&listFlags.all, "all", false, "If set return all installable and installed cores, including manually installed.")
4243
return listCommand
4344
}
4445

4546
var listFlags struct {
4647
updatableOnly bool
48+
all bool
4749
}
4850

4951
func runListCommand(cmd *cobra.Command, args []string) {
@@ -58,6 +60,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
5860
platforms, err := core.GetPlatforms(&rpc.PlatformListReq{
5961
Instance: inst,
6062
UpdatableOnly: listFlags.updatableOnly,
63+
All: listFlags.all,
6164
})
6265
if err != nil {
6366
feedback.Errorf("Error listing platforms: %v", err)

‎commands/core.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
5151
}
5252

5353
result := &rpc.Platform{
54-
ID: platformRelease.Platform.String(),
55-
Name: platformRelease.Platform.Name,
56-
Maintainer: platformRelease.Platform.Package.Maintainer,
57-
Website: platformRelease.Platform.Package.WebsiteURL,
58-
Email: platformRelease.Platform.Package.Email,
59-
Boards: boards,
60-
Latest: platformRelease.Version.String(),
54+
ID: platformRelease.Platform.String(),
55+
Name: platformRelease.Platform.Name,
56+
Maintainer: platformRelease.Platform.Package.Maintainer,
57+
Website: platformRelease.Platform.Package.WebsiteURL,
58+
Email: platformRelease.Platform.Package.Email,
59+
Boards: boards,
60+
Latest: platformRelease.Version.String(),
61+
ManuallyInstalled: platformRelease.Platform.ManuallyInstalled,
6162
}
6263

6364
return result

‎commands/core/list.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ func GetPlatforms(req *rpc.PlatformListReq) ([]*rpc.Platform, error) {
3939
for _, targetPackage := range packageManager.Packages {
4040
for _, platform := range targetPackage.Platforms {
4141
platformRelease := packageManager.GetInstalledPlatformRelease(platform)
42+
43+
// If both All and UpdatableOnly are set All takes precedence
44+
if req.All {
45+
installedVersion := ""
46+
if platformRelease == nil {
47+
platformRelease = platform.GetLatestRelease()
48+
} else {
49+
installedVersion = platformRelease.Version.String()
50+
}
51+
rpcPlatform := commands.PlatformReleaseToRPC(platform.GetLatestRelease())
52+
rpcPlatform.Installed = installedVersion
53+
res = append(res, rpcPlatform)
54+
continue
55+
}
56+
4257
if platformRelease != nil {
4358
if req.UpdatableOnly {
4459
if latest := platform.GetLatestRelease(); latest == nil || latest == platformRelease {

‎commands/core/search.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ func PlatformSearch(req *rpc.PlatformSearchReq) (*rpc.PlatformSearchResp, error)
5050
for _, targetPackage := range pm.Packages {
5151
for _, platform := range targetPackage.Platforms {
5252
// discard invalid platforms
53-
if platform == nil || platform.Name == "" {
53+
// Users can install platforms manually in the Sketchbook hardware folder,
54+
// the core search command must operate only on platforms installed through
55+
// the PlatformManager, thus we skip the manually installed ones.
56+
if platform == nil || platform.Name == "" || platform.ManuallyInstalled {
5457
continue
5558
}
5659

‎legacy/builder/test/hardware_loader_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ func TestLoadHardware(t *testing.T) {
4949
require.NotNil(t, packages["arduino"])
5050
require.Equal(t, 2, len(packages["arduino"].Platforms))
5151

52-
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases[""].Boards["uno"].BoardID)
53-
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases[""].Boards["uno"].Properties.Get("_id"))
52+
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["uno"].BoardID)
53+
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["uno"].Properties.Get("_id"))
5454

55-
require.Equal(t, "yun", packages["arduino"].Platforms["avr"].Releases[""].Boards["yun"].BoardID)
56-
require.Equal(t, "true", packages["arduino"].Platforms["avr"].Releases[""].Boards["yun"].Properties.Get("upload.wait_for_upload_port"))
55+
require.Equal(t, "yun", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["yun"].BoardID)
56+
require.Equal(t, "true", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["yun"].Properties.Get("upload.wait_for_upload_port"))
5757

58-
require.Equal(t, "{build.usb_flags}", packages["arduino"].Platforms["avr"].Releases[""].Boards["robotMotor"].Properties.Get("build.extra_flags"))
58+
require.Equal(t, "{build.usb_flags}", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["robotMotor"].Properties.Get("build.extra_flags"))
5959

60-
require.Equal(t, "arduino_due_x", packages["arduino"].Platforms["sam"].Releases[""].Boards["arduino_due_x"].BoardID)
60+
require.Equal(t, "arduino_due_x", packages["arduino"].Platforms["sam"].Releases["1.6.7"].Boards["arduino_due_x"].BoardID)
6161

62-
require.Equal(t, "ATmega123", packages["arduino"].Platforms["avr"].Releases[""].Boards["diecimila"].Properties.Get("menu.cpu.atmega123"))
62+
require.Equal(t, "ATmega123", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["diecimila"].Properties.Get("menu.cpu.atmega123"))
6363

6464
avrPlatform := packages["arduino"].Platforms["avr"]
65-
require.Equal(t, "Arduino AVR Boards", avrPlatform.Releases[""].Properties.Get("name"))
66-
require.Equal(t, "-v", avrPlatform.Releases[""].Properties.Get("tools.avrdude.bootloader.params.verbose"))
67-
require.Equal(t, "/my/personal/avrdude", avrPlatform.Releases[""].Properties.Get("tools.avrdude.cmd.path"))
65+
require.Equal(t, "Arduino AVR Boards", avrPlatform.Releases["1.6.10"].Properties.Get("name"))
66+
require.Equal(t, "-v", avrPlatform.Releases["1.6.10"].Properties.Get("tools.avrdude.bootloader.params.verbose"))
67+
require.Equal(t, "/my/personal/avrdude", avrPlatform.Releases["1.6.10"].Properties.Get("tools.avrdude.cmd.path"))
6868

69-
require.Equal(t, "AVRISP mkII", avrPlatform.Releases[""].Programmers["avrispmkii"].Name)
69+
require.Equal(t, "AVRISP mkII", avrPlatform.Releases["1.6.10"].Programmers["avrispmkii"].Name)
7070

7171
//require.Equal(t, "{runtime.tools.ctags.path}", packages.Properties.Get("tools.ctags.path"])
7272
//require.Equal(t, "\"{cmd.path}\" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives \"{source_file}\"", packages.Properties.Get("tools.ctags.pattern"])
@@ -103,17 +103,17 @@ func TestLoadHardwareMixingUserHardwareFolder(t *testing.T) {
103103
require.NotNil(t, packages["arduino"])
104104
require.Equal(t, 2, len(packages["arduino"].Platforms))
105105

106-
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases[""].Boards["uno"].BoardID)
107-
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases[""].Boards["uno"].Properties.Get("_id"))
106+
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["uno"].BoardID)
107+
require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["uno"].Properties.Get("_id"))
108108

109-
require.Equal(t, "yun", packages["arduino"].Platforms["avr"].Releases[""].Boards["yun"].BoardID)
110-
require.Equal(t, "true", packages["arduino"].Platforms["avr"].Releases[""].Boards["yun"].Properties.Get("upload.wait_for_upload_port"))
109+
require.Equal(t, "yun", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["yun"].BoardID)
110+
require.Equal(t, "true", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["yun"].Properties.Get("upload.wait_for_upload_port"))
111111

112-
require.Equal(t, "{build.usb_flags}", packages["arduino"].Platforms["avr"].Releases[""].Boards["robotMotor"].Properties.Get("build.extra_flags"))
112+
require.Equal(t, "{build.usb_flags}", packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards["robotMotor"].Properties.Get("build.extra_flags"))
113113

114-
require.Equal(t, "arduino_due_x", packages["arduino"].Platforms["sam"].Releases[""].Boards["arduino_due_x"].BoardID)
114+
require.Equal(t, "arduino_due_x", packages["arduino"].Platforms["sam"].Releases["1.6.7"].Boards["arduino_due_x"].BoardID)
115115

116-
avrPlatform := packages["arduino"].Platforms["avr"].Releases[""]
116+
avrPlatform := packages["arduino"].Platforms["avr"].Releases["1.6.10"]
117117
require.Equal(t, "Arduino AVR Boards", avrPlatform.Properties.Get("name"))
118118
require.Equal(t, "-v", avrPlatform.Properties.Get("tools.avrdude.bootloader.params.verbose"))
119119
require.Equal(t, "/my/personal/avrdude", avrPlatform.Properties.Get("tools.avrdude.cmd.path"))
@@ -128,7 +128,7 @@ func TestLoadHardwareMixingUserHardwareFolder(t *testing.T) {
128128
require.NotNil(t, packages["my_avr_platform"])
129129
myAVRPlatform := packages["my_avr_platform"]
130130
//require.Equal(t, "hello world", myAVRPlatform.Properties.Get("example"))
131-
myAVRPlatformAvrArch := myAVRPlatform.Platforms["avr"].Releases[""]
131+
myAVRPlatformAvrArch := myAVRPlatform.Platforms["avr"].Releases["9.9.9"]
132132
require.Equal(t, "custom_yun", myAVRPlatformAvrArch.Boards["custom_yun"].BoardID)
133133

134134
require.False(t, myAVRPlatformAvrArch.Properties.ContainsKey("preproc.includes.flags"))
@@ -219,15 +219,15 @@ func TestLoadLotsOfHardware(t *testing.T) {
219219
require.NotNil(t, packages["my_avr_platform"])
220220

221221
require.Equal(t, 3, len(packages["arduino"].Platforms))
222-
require.Equal(t, 20, len(packages["arduino"].Platforms["avr"].Releases[""].Boards))
223-
require.Equal(t, 2, len(packages["arduino"].Platforms["sam"].Releases[""].Boards))
222+
require.Equal(t, 20, len(packages["arduino"].Platforms["avr"].Releases["1.6.10"].Boards))
223+
require.Equal(t, 2, len(packages["arduino"].Platforms["sam"].Releases["1.6.7"].Boards))
224224
require.Equal(t, 3, len(packages["arduino"].Platforms["samd"].Releases["1.6.5"].Boards))
225225

226226
require.Equal(t, 1, len(packages["my_avr_platform"].Platforms))
227-
require.Equal(t, 2, len(packages["my_avr_platform"].Platforms["avr"].Releases[""].Boards))
227+
require.Equal(t, 2, len(packages["my_avr_platform"].Platforms["avr"].Releases["9.9.9"].Boards))
228228

229229
if runtime.GOOS != "windows" {
230230
require.Equal(t, 1, len(packages["my_symlinked_avr_platform"].Platforms))
231-
require.Equal(t, 2, len(packages["my_symlinked_avr_platform"].Platforms["avr"].Releases[""].Boards))
231+
require.Equal(t, 2, len(packages["my_symlinked_avr_platform"].Platforms["avr"].Releases["9.9.9"].Boards))
232232
}
233233
}

‎rpc/commands/core.pb.go

Lines changed: 60 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/commands/core.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ message PlatformListReq {
109109
// Set to true to only list platforms which have a newer version available
110110
// than the one currently installed.
111111
bool updatable_only = 2;
112+
// Set to true to list platforms installed manually in the user' sketchbook
113+
// hardware folder, installed with the PlatformManager through the CLI or IDE
114+
// and that are available to install
115+
bool all = 3;
112116
}
113117

114118
message PlatformListResp {
@@ -137,6 +141,9 @@ message Platform {
137141
// not installed, this is an arbitrary list of board names provided by the
138142
// platform author for display and may not match boards.txt.
139143
repeated Board Boards = 8;
144+
// If true this Platform has been installed manually in the user' sketchbook
145+
// hardware folder
146+
bool ManuallyInstalled = 9;
140147
}
141148

142149
message Board {

‎test/test_compile.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import tempfile
1818
import hashlib
1919
import shutil
20+
from git import Repo
2021
from pathlib import Path
2122
import simplejson as json
2223

@@ -758,3 +759,131 @@ def test_compile_with_only_compilation_database_flag(run_command, data_dir):
758759

759760
# Verifies no binaries are exported
760761
assert not build_path.exists()
762+
763+
764+
def test_compile_using_platform_local_txt(run_command, data_dir):
765+
assert run_command("update")
766+
767+
assert run_command("core install arduino:avr@1.8.3")
768+
769+
sketch_name = "CompileSketchUsingPlatformLocalTxt"
770+
sketch_path = Path(data_dir, sketch_name)
771+
fqbn = "arduino:avr:uno"
772+
773+
assert run_command(f"sketch new {sketch_path}")
774+
775+
# Verifies compilation works without issues
776+
assert run_command(f"compile --clean -b {fqbn} {sketch_path}")
777+
778+
# Overrides default platform compiler with an unexisting one
779+
platform_local_txt = Path(data_dir, "packages", "arduino", "hardware", "avr", "1.8.3", "platform.local.txt")
780+
platform_local_txt.write_text("compiler.c.cmd=my-compiler-that-does-not-exist")
781+
782+
# Verifies compilation now fails because compiler is not found
783+
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
784+
assert res.failed
785+
assert "my-compiler-that-does-not-exist" in res.stderr
786+
787+
788+
def test_compile_using_boards_local_txt(run_command, data_dir):
789+
assert run_command("update")
790+
791+
assert run_command("core install arduino:avr@1.8.3")
792+
793+
sketch_name = "CompileSketchUsingBoardsLocalTxt"
794+
sketch_path = Path(data_dir, sketch_name)
795+
# Use a made up board
796+
fqbn = "arduino:avr:nessuno"
797+
798+
assert run_command(f"sketch new {sketch_path}")
799+
800+
# Verifies compilation fails because board doesn't exist
801+
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
802+
assert res.failed
803+
assert "Error during build: Error resolving FQBN: board arduino:avr@1.8.3:nessuno not found" in res.stderr
804+
805+
# Use custom boards.local.txt with made arduino:avr:nessuno board
806+
boards_local_txt = Path(data_dir, "packages", "arduino", "hardware", "avr", "1.8.3", "boards.local.txt")
807+
shutil.copyfile(Path(__file__).parent / "testdata" / "boards.local.txt", boards_local_txt)
808+
809+
assert run_command(f"compile --clean -b {fqbn} {sketch_path}")
810+
811+
812+
def test_compile_manually_installed_platform(run_command, data_dir):
813+
assert run_command("update")
814+
815+
sketch_name = "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
816+
sketch_path = Path(data_dir, sketch_name)
817+
fqbn = "arduino-beta-development:avr:uno"
818+
assert run_command(f"sketch new {sketch_path}")
819+
820+
# Manually installs a core in sketchbooks hardware folder
821+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
822+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
823+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
824+
825+
# Installs also the same core via CLI so all the necessary tools are installed
826+
assert run_command("core install arduino:avr@1.8.3")
827+
828+
# Verifies compilation works without issues
829+
assert run_command(f"compile --clean -b {fqbn} {sketch_path}")
830+
831+
832+
def test_compile_manually_installed_platform_using_platform_local_txt(run_command, data_dir):
833+
assert run_command("update")
834+
835+
sketch_name = "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
836+
sketch_path = Path(data_dir, sketch_name)
837+
fqbn = "arduino-beta-development:avr:uno"
838+
assert run_command(f"sketch new {sketch_path}")
839+
840+
# Manually installs a core in sketchbooks hardware folder
841+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
842+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
843+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
844+
845+
# Installs also the same core via CLI so all the necessary tools are installed
846+
assert run_command("core install arduino:avr@1.8.3")
847+
848+
# Verifies compilation works without issues
849+
assert run_command(f"compile --clean -b {fqbn} {sketch_path}")
850+
851+
# Overrides default platform compiler with an unexisting one
852+
platform_local_txt = Path(repo_dir, "platform.local.txt")
853+
platform_local_txt.write_text("compiler.c.cmd=my-compiler-that-does-not-exist")
854+
855+
# Verifies compilation now fails because compiler is not found
856+
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
857+
assert res.failed
858+
assert "my-compiler-that-does-not-exist" in res.stderr
859+
860+
861+
def test_compile_manually_installed_platform_using_boards_local_txt(run_command, data_dir):
862+
assert run_command("update")
863+
864+
sketch_name = "CompileSketchManuallyInstalledPlatformUsingBoardsLocalTxt"
865+
sketch_path = Path(data_dir, sketch_name)
866+
fqbn = "arduino-beta-development:avr:nessuno"
867+
assert run_command(f"sketch new {sketch_path}")
868+
869+
# Manually installs a core in sketchbooks hardware folder
870+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
871+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
872+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
873+
874+
# Installs also the same core via CLI so all the necessary tools are installed
875+
assert run_command("core install arduino:avr@1.8.3")
876+
877+
# Verifies compilation fails because board doesn't exist
878+
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
879+
assert res.failed
880+
assert (
881+
"Error during build: Error resolving FQBN: board arduino-beta-development:avr@1.8.3:nessuno not found"
882+
in res.stderr
883+
)
884+
885+
# Use custom boards.local.txt with made arduino:avr:nessuno board
886+
boards_local_txt = Path(repo_dir, "boards.local.txt")
887+
shutil.copyfile(Path(__file__).parent / "testdata" / "boards.local.txt", boards_local_txt)
888+
889+
assert run_command(f"compile --clean -b {fqbn} {sketch_path}")

‎test/test_core.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import simplejson as json
1919
import tempfile
2020
import hashlib
21+
from git import Repo
2122
from pathlib import Path
2223

2324

@@ -363,3 +364,79 @@ def test_core_update_with_local_url(run_command):
363364
res = run_command(f'core update-index --additional-urls="file://{test_index}"')
364365
assert res.ok
365366
assert "Updating index: test_index.json downloaded" in res.stdout
367+
368+
369+
def test_core_search_manually_installed_cores_not_printed(run_command, data_dir):
370+
assert run_command("core update-index")
371+
372+
# Verifies only cores in board manager are shown
373+
res = run_command("core search --format json")
374+
assert res.ok
375+
cores = json.loads(res.stdout)
376+
assert len(cores) == 17
377+
378+
# Manually installs a core in sketchbooks hardware folder
379+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
380+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
381+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
382+
383+
# Verifies manually installed core is not shown
384+
res = run_command("core search --format json")
385+
assert res.ok
386+
cores = json.loads(res.stdout)
387+
assert len(cores) == 17
388+
mapped = {core["ID"]: core for core in cores}
389+
core_id = "arduino-beta-development:avr"
390+
assert core_id not in mapped
391+
392+
393+
def test_core_list_all_manually_installed_core(run_command, data_dir):
394+
assert run_command("core update-index")
395+
396+
# Verifies only cores in board manager are shown
397+
res = run_command("core list --all --format json")
398+
assert res.ok
399+
cores = json.loads(res.stdout)
400+
assert len(cores) == 17
401+
402+
# Manually installs a core in sketchbooks hardware folder
403+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
404+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
405+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
406+
407+
# Verifies manually installed core is shown
408+
res = run_command("core list --all --format json")
409+
assert res.ok
410+
cores = json.loads(res.stdout)
411+
assert len(cores) == 18
412+
mapped = {core["ID"]: core for core in cores}
413+
expected_core_id = "arduino-beta-development:avr"
414+
assert expected_core_id in mapped
415+
assert "Arduino AVR Boards" == mapped[expected_core_id]["Name"]
416+
assert "1.8.3" == mapped[expected_core_id]["Latest"]
417+
418+
419+
def test_core_list_updatable_all_flags(run_command, data_dir):
420+
assert run_command("core update-index")
421+
422+
# Verifies only cores in board manager are shown
423+
res = run_command("core list --all --updatable --format json")
424+
assert res.ok
425+
cores = json.loads(res.stdout)
426+
assert len(cores) == 17
427+
428+
# Manually installs a core in sketchbooks hardware folder
429+
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
430+
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
431+
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
432+
433+
# Verifies using both --updatable and --all flags --all takes precedence
434+
res = run_command("core list --all --updatable --format json")
435+
assert res.ok
436+
cores = json.loads(res.stdout)
437+
assert len(cores) == 18
438+
mapped = {core["ID"]: core for core in cores}
439+
expected_core_id = "arduino-beta-development:avr"
440+
assert expected_core_id in mapped
441+
assert "Arduino AVR Boards" == mapped[expected_core_id]["Name"]
442+
assert "1.8.3" == mapped[expected_core_id]["Latest"]

‎test/testdata/boards.local.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
nessuno.name=Arduino Nessuno
2+
nessuno.vid.0=0x2341
3+
nessuno.pid.0=0x0043
4+
nessuno.vid.1=0x2341
5+
nessuno.pid.1=0x0001
6+
nessuno.vid.2=0x2A03
7+
nessuno.pid.2=0x0043
8+
nessuno.vid.3=0x2341
9+
nessuno.pid.3=0x0243
10+
nessuno.upload.tool=avrdude
11+
nessuno.upload.protocol=arduino
12+
nessuno.upload.maximum_size=32256
13+
nessuno.upload.maximum_data_size=2048
14+
nessuno.upload.speed=115200
15+
nessuno.bootloader.tool=avrdude
16+
nessuno.bootloader.low_fuses=0xFF
17+
nessuno.bootloader.high_fuses=0xDE
18+
nessuno.bootloader.extended_fuses=0xFD
19+
nessuno.bootloader.unlock_bits=0x3F
20+
nessuno.bootloader.lock_bits=0x0F
21+
nessuno.bootloader.file=optiboot/optiboot_atmega328.hex
22+
nessuno.build.mcu=atmega328p
23+
nessuno.build.f_cpu=16000000L
24+
nessuno.build.board=AVR_NESSUNO
25+
nessuno.build.core=arduino
26+
nessuno.build.variant=standard

0 commit comments

Comments
 (0)
Please sign in to comment.