Skip to content

Commit b9b7a87

Browse files
authored
Fix board attach panic if sketch.json doesn't exist (#1405)
1 parent ec027a7 commit b9b7a87

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Diff for: arduino/sketch/sketch.go

+1
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()

Diff for: i18n/data/en.po

+9-9
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ msgstr "can't find dependencies for platform %[1]s: %[2]w"
21282128
msgid "can't find latest release of %s"
21292129
msgstr "can't find latest release of %s"
21302130

2131-
#: arduino/sketch/sketch.go:100
2131+
#: arduino/sketch/sketch.go:101
21322132
msgid "can't find main Sketch file in %s"
21332133
msgstr "can't find main Sketch file in %s"
21342134

@@ -2277,7 +2277,7 @@ msgstr "data section exceeds available space in board"
22772277
msgid "debugging not supported for board %s"
22782278
msgstr "debugging not supported for board %s"
22792279

2280-
#: arduino/sketch/sketch.go:206
2280+
#: arduino/sketch/sketch.go:207
22812281
msgid "decoding sketch metadata: %s"
22822282
msgstr "decoding sketch metadata: %s"
22832283

@@ -2351,7 +2351,7 @@ msgstr "downloading library_index.json.sig"
23512351
msgid "downloading tool %[1]s: %[2]s"
23522352
msgstr "downloading tool %[1]s: %[2]s"
23532353

2354-
#: arduino/sketch/sketch.go:195
2354+
#: arduino/sketch/sketch.go:196
23552355
msgid "encoding sketch metadata: %s"
23562356
msgstr "encoding sketch metadata: %s"
23572357

@@ -2508,7 +2508,7 @@ msgstr "getting parent dir of %[1]s: %[2]s"
25082508
msgid "getting tool dependencies for platform %[1]s: %[2]s"
25092509
msgstr "getting tool dependencies for platform %[1]s: %[2]s"
25102510

2511-
#: arduino/sketch/sketch.go:150
2511+
#: arduino/sketch/sketch.go:151
25122512
msgid "importing sketch metadata: %s"
25132513
msgstr "importing sketch metadata: %s"
25142514

@@ -2891,7 +2891,7 @@ msgstr "no unique root dir in archive, found '%[1]s' and '%[2]s'"
28912891
msgid "no upload port provided"
28922892
msgstr "no upload port provided"
28932893

2894-
#: arduino/sketch/sketch.go:258
2894+
#: arduino/sketch/sketch.go:259
28952895
msgid "no valid sketch found in %[1]s: missing %[2]s"
28962896
msgstr "no valid sketch found in %[1]s: missing %[2]s"
28972897

@@ -3076,7 +3076,7 @@ msgstr "reading directory %[1]s: %[2]s"
30763076
msgid "reading file %[1]s: %[2]s"
30773077
msgstr "reading file %[1]s: %[2]s"
30783078

3079-
#: arduino/sketch/sketch.go:228
3079+
#: arduino/sketch/sketch.go:229
30803080
msgid "reading files: %v"
30813081
msgstr "reading files: %v"
30823082

@@ -3100,7 +3100,7 @@ msgstr "reading library_index.json: %s"
31003100
msgid "reading package root dir: %s"
31013101
msgstr "reading package root dir: %s"
31023102

3103-
#: arduino/sketch/sketch.go:187
3103+
#: arduino/sketch/sketch.go:188
31043104
msgid "reading sketch metadata %[1]s: %[2]s"
31053105
msgstr "reading sketch metadata %[1]s: %[2]s"
31063106

@@ -3341,7 +3341,7 @@ msgstr "unknown package %s"
33413341
msgid "unknown platform %s:%s"
33423342
msgstr "unknown platform %s:%s"
33433343

3344-
#: arduino/sketch/sketch.go:141
3344+
#: arduino/sketch/sketch.go:142
33453345
msgid "unknown sketch file extension '%s'"
33463346
msgstr "unknown sketch file extension '%s'"
33473347

@@ -3394,7 +3394,7 @@ msgstr "writing library_index.json"
33943394
msgid "writing library_index.json.sig"
33953395
msgstr "writing library_index.json.sig"
33963396

3397-
#: arduino/sketch/sketch.go:211
3397+
#: arduino/sketch/sketch.go:212
33983398
msgid "writing sketch metadata %[1]s: %[2]s"
33993399
msgstr "writing sketch metadata %[1]s: %[2]s"
34003400

Diff for: i18n/rice-box.go

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: test/test_board.py

+13
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)