Skip to content

Fix board attach panic if sketch.json doesn't exist #1405

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 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arduino/sketch/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func New(path *paths.Path) (*Sketch, error) {
OtherSketchFiles: paths.PathList{},
AdditionalFiles: paths.PathList{},
RootFolderFiles: paths.PathList{},
Metadata: new(Metadata),
}

err := sketch.checkSketchCasing()
Expand Down
18 changes: 9 additions & 9 deletions i18n/data/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ msgstr "can't find dependencies for platform %[1]s: %[2]w"
msgid "can't find latest release of %s"
msgstr "can't find latest release of %s"

#: arduino/sketch/sketch.go:100
#: arduino/sketch/sketch.go:101
msgid "can't find main Sketch file in %s"
msgstr "can't find main Sketch file in %s"

Expand Down Expand Up @@ -2277,7 +2277,7 @@ msgstr "data section exceeds available space in board"
msgid "debugging not supported for board %s"
msgstr "debugging not supported for board %s"

#: arduino/sketch/sketch.go:206
#: arduino/sketch/sketch.go:207
msgid "decoding sketch metadata: %s"
msgstr "decoding sketch metadata: %s"

Expand Down Expand Up @@ -2351,7 +2351,7 @@ msgstr "downloading library_index.json.sig"
msgid "downloading tool %[1]s: %[2]s"
msgstr "downloading tool %[1]s: %[2]s"

#: arduino/sketch/sketch.go:195
#: arduino/sketch/sketch.go:196
msgid "encoding sketch metadata: %s"
msgstr "encoding sketch metadata: %s"

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

#: arduino/sketch/sketch.go:150
#: arduino/sketch/sketch.go:151
msgid "importing sketch metadata: %s"
msgstr "importing sketch metadata: %s"

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

#: arduino/sketch/sketch.go:258
#: arduino/sketch/sketch.go:259
msgid "no valid sketch found in %[1]s: missing %[2]s"
msgstr "no valid sketch found in %[1]s: missing %[2]s"

Expand Down Expand Up @@ -3076,7 +3076,7 @@ msgstr "reading directory %[1]s: %[2]s"
msgid "reading file %[1]s: %[2]s"
msgstr "reading file %[1]s: %[2]s"

#: arduino/sketch/sketch.go:228
#: arduino/sketch/sketch.go:229
msgid "reading files: %v"
msgstr "reading files: %v"

Expand All @@ -3100,7 +3100,7 @@ msgstr "reading library_index.json: %s"
msgid "reading package root dir: %s"
msgstr "reading package root dir: %s"

#: arduino/sketch/sketch.go:187
#: arduino/sketch/sketch.go:188
msgid "reading sketch metadata %[1]s: %[2]s"
msgstr "reading sketch metadata %[1]s: %[2]s"

Expand Down Expand Up @@ -3341,7 +3341,7 @@ msgstr "unknown package %s"
msgid "unknown platform %s:%s"
msgstr "unknown platform %s:%s"

#: arduino/sketch/sketch.go:141
#: arduino/sketch/sketch.go:142
msgid "unknown sketch file extension '%s'"
msgstr "unknown sketch file extension '%s'"

Expand Down Expand Up @@ -3394,7 +3394,7 @@ msgstr "writing library_index.json"
msgid "writing library_index.json.sig"
msgstr "writing library_index.json.sig"

#: arduino/sketch/sketch.go:211
#: arduino/sketch/sketch.go:212
msgid "writing sketch metadata %[1]s: %[2]s"
msgstr "writing sketch metadata %[1]s: %[2]s"

Expand Down
14 changes: 7 additions & 7 deletions i18n/rice-box.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions test/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,16 @@ def test_board_search(run_command, data_dir):
installed_boards = {board["fqbn"]: board for board in data if "fqbn" in board}
assert "arduino-beta-development:samd:mkr1000" in installed_boards
assert "Arduino MKR1000" == installed_boards["arduino-beta-development:samd:mkr1000"]["name"]


def test_board_attach_without_sketch_json(run_command, data_dir):
run_command("update")

sketch_name = "BoardAttachWithoutSketchJson"
sketch_path = Path(data_dir, sketch_name)
fqbn = "arduino:avr:uno"

# Create a test sketch
assert run_command(f"sketch new {sketch_path}")

assert run_command(f"board attach {fqbn} {sketch_path}")