Skip to content

Commit 6bab4d0

Browse files
committed
Added check for nil-pointer panic
1 parent 3716816 commit 6bab4d0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

commands/commands_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,13 @@ func TestCompileCommands(t *testing.T) {
493493
require.Zero(t, exitCode, "exit code")
494494
require.Contains(t, string(d), "Sketch created")
495495

496-
// Build sketch for arduino:avr:uno
496+
// Build sketch without FQBN
497497
test1 := currSketchbookDir.Join("Test1").String()
498+
exitCode, d = executeWithArgs(t, "compile", test1)
499+
require.NotZero(t, exitCode, "exit code")
500+
require.Contains(t, string(d), "No Fully Qualified Board Name provided")
501+
502+
// Build sketch for arduino:avr:uno
498503
exitCode, d = executeWithArgs(t, "compile", "-b", "arduino:avr:uno", test1)
499504
require.Zero(t, exitCode, "exit code")
500505
require.Contains(t, string(d), "Sketch uses")

commands/compile/compile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/arduino/arduino-cli/commands"
3232
"github.com/arduino/arduino-cli/commands/core"
3333
"github.com/arduino/arduino-cli/common/formatter"
34-
"github.com/arduino/go-paths-helper"
34+
paths "github.com/arduino/go-paths-helper"
3535
properties "github.com/arduino/go-properties-orderedmap"
3636
"github.com/sirupsen/logrus"
3737
"github.com/spf13/cobra"
@@ -109,7 +109,7 @@ func run(cmd *cobra.Command, args []string) {
109109
os.Exit(commands.ErrGeneric)
110110
}
111111

112-
if flags.fqbn == "" && sketch != nil {
112+
if flags.fqbn == "" && sketch != nil && sketch.Metadata != nil {
113113
flags.fqbn = sketch.Metadata.CPU.Fqbn
114114
}
115115
if flags.fqbn == "" {

0 commit comments

Comments
 (0)