Skip to content

Commit 86510f4

Browse files
committed
Fix board attach panic if sketch.json doesn't exist
1 parent ec027a7 commit 86510f4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

arduino/sketch/sketch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func New(path *paths.Path) (*Sketch, error) {
8686
OtherSketchFiles: paths.PathList{},
8787
AdditionalFiles: paths.PathList{},
8888
RootFolderFiles: paths.PathList{},
89+
Metadata: new(Metadata),
8990
}
9091

9192
err := sketch.checkSketchCasing()

test/test_board.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,16 @@ def test_board_search(run_command, data_dir):
644644
installed_boards = {board["fqbn"]: board for board in data if "fqbn" in board}
645645
assert "arduino-beta-development:samd:mkr1000" in installed_boards
646646
assert "Arduino MKR1000" == installed_boards["arduino-beta-development:samd:mkr1000"]["name"]
647+
648+
649+
def test_board_attach_without_sketch_json(run_command, data_dir):
650+
run_command("update")
651+
652+
sketch_name = "BoardAttachWithoutSketchJson"
653+
sketch_path = Path(data_dir, sketch_name)
654+
fqbn = "arduino:avr:uno"
655+
656+
# Create a test sketch
657+
assert run_command(f"sketch new {sketch_path}")
658+
659+
assert run_command(f"board attach {fqbn} {sketch_path}")

0 commit comments

Comments
 (0)