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

+6-1
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

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