-
-
Notifications
You must be signed in to change notification settings - Fork 405
Fix loading platforms with malformed boards.txt #1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
68db33d
Fix loading platforms with malformed boards.txt
silvanocerza 60a8369
[skip changelog] Fix legacy tests
silvanocerza 9dc0195
[skip changelog] Remove unecessary sentence from documentation
silvanocerza 1106bb6
[skip changelog] Fix some docs and comments
silvanocerza 2df7ce0
Fix board skipping logic
silvanocerza 61185c6
[skip changelog] Fix unit tests
silvanocerza e0feac8
Fix panic if a board has a property that starts with menu
silvanocerza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
legacy/builder/test/user_hardware/my_avr_platform/avr/boards.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
menu.cpu=Processor | ||
|
||
custom_yun.name=Arduino Yún | ||
custom_yun.upload.via_ssh=true | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
# a commercial license, send an email to [email protected]. | ||
import os | ||
import datetime | ||
import shutil | ||
import time | ||
import platform | ||
import pytest | ||
|
@@ -675,3 +676,39 @@ def test_core_list_platform_without_platform_txt(run_command, data_dir): | |
core = cores[0] | ||
assert core["id"] == "some-packager:some-arch" | ||
assert core["name"] == "some-packager-some-arch" | ||
|
||
|
||
def test_core_with_wrong_custom_board_options_is_loaded(run_command, data_dir): | ||
test_platform_name = "platform_with_wrong_custom_board_options" | ||
platform_install_dir = Path(data_dir, "hardware", "arduino-beta-dev", test_platform_name) | ||
platform_install_dir.mkdir(parents=True) | ||
|
||
# Install platform in Sketchbook hardware dir | ||
shutil.copytree( | ||
Path(__file__).parent / "testdata" / test_platform_name, platform_install_dir, dirs_exist_ok=True, | ||
) | ||
|
||
assert run_command("update") | ||
|
||
res = run_command("core list --format json") | ||
assert res.ok | ||
|
||
cores = json.loads(res.stdout) | ||
mapped = {core["id"]: core for core in cores} | ||
assert len(mapped) == 1 | ||
# Verifies platform is loaded except excluding board with wrong options | ||
assert "arduino-beta-dev:platform_with_wrong_custom_board_options" in mapped | ||
boards = {b["fqbn"]: b for b in mapped["arduino-beta-dev:platform_with_wrong_custom_board_options"]["boards"]} | ||
assert len(boards) == 1 | ||
# Verify board with malformed options is not loaded | ||
assert "arduino-beta-dev:platform_with_wrong_custom_board_options:nessuno" not in boards | ||
# Verify other board is loaded | ||
assert "arduino-beta-dev:platform_with_wrong_custom_board_options:altra" in boards | ||
# Verify warning is shown to user | ||
assert ( | ||
"Error initializing instance: " | ||
+ "loading platform release arduino-beta-dev:[email protected]: " | ||
+ "loading boards: " | ||
+ "skipping loading of boards arduino-beta-dev:platform_with_wrong_custom_board_options:nessuno: " | ||
+ "malformed custom board options" | ||
) in res.stderr |
62 changes: 62 additions & 0 deletions
62
test/testdata/platform_with_wrong_custom_board_options/boards.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
menu.cpu=Processor | ||
|
||
nessuno.name=Arduino Nessuno | ||
nessuno.vid.0=0x2341 | ||
nessuno.pid.0=0x0043 | ||
nessuno.vid.1=0x2341 | ||
nessuno.pid.1=0x0001 | ||
nessuno.vid.2=0x2A03 | ||
nessuno.pid.2=0x0043 | ||
nessuno.vid.3=0x2341 | ||
nessuno.pid.3=0x0243 | ||
nessuno.upload.tool=avrdude | ||
nessuno.upload.protocol=arduino | ||
nessuno.upload.maximum_size=32256 | ||
nessuno.upload.maximum_data_size=2048 | ||
nessuno.upload.speed=115200 | ||
nessuno.bootloader.tool=avrdude | ||
nessuno.bootloader.low_fuses=0xFF | ||
nessuno.bootloader.high_fuses=0xDE | ||
nessuno.bootloader.extended_fuses=0xFD | ||
nessuno.bootloader.unlock_bits=0x3F | ||
nessuno.bootloader.lock_bits=0x0F | ||
nessuno.bootloader.file=optiboot/optiboot_atmega328.hex | ||
nessuno.build.mcu=atmega328p | ||
nessuno.build.f_cpu=16000000L | ||
nessuno.build.board=AVR_NESSUNO | ||
nessuno.build.core=arduino | ||
nessuno.build.variant=standard | ||
|
||
nessuno.menu.cache.on=Enabled | ||
nessuno.menu.cache.on.build.cache_flags=-DENABLE_CACHE | ||
nessuno.menu.cache.off=Disabled | ||
nessuno.menu.cache.off.build.cache_flags= | ||
|
||
altra.name=Arduino Altra | ||
altra.vid.0=0x2341 | ||
altra.pid.0=0x0043 | ||
altra.vid.1=0x2341 | ||
altra.pid.1=0x0001 | ||
altra.vid.2=0x2A03 | ||
altra.pid.2=0x0043 | ||
altra.vid.3=0x2341 | ||
altra.pid.3=0x0243 | ||
altra.upload.tool=avrdude | ||
altra.upload.protocol=arduino | ||
altra.upload.maximum_size=32256 | ||
altra.upload.maximum_data_size=2048 | ||
altra.upload.speed=115200 | ||
altra.bootloader.tool=avrdude | ||
altra.bootloader.low_fuses=0xFF | ||
altra.bootloader.high_fuses=0xDE | ||
altra.bootloader.extended_fuses=0xFD | ||
altra.bootloader.unlock_bits=0x3F | ||
altra.bootloader.lock_bits=0x0F | ||
altra.bootloader.file=optiboot/optiboot_atmega328.hex | ||
altra.build.mcu=atmega328p | ||
altra.build.f_cpu=16000000L | ||
altra.build.board=AVR_ALTRA | ||
altra.build.core=arduino | ||
altra.build.variant=standard | ||
altra.menu.cpu.atmega328=ATmega328P | ||
altra.menu.cpu.atmega168=ATmega168 |
2 changes: 2 additions & 0 deletions
2
test/testdata/platform_with_wrong_custom_board_options/platform.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name=Arduino Test Boards | ||
version=4.2.0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.