Commit 6bab4d0b authored by Cristian Maglie's avatar Cristian Maglie

Added check for nil-pointer panic

parent 37168166
...@@ -493,8 +493,13 @@ func TestCompileCommands(t *testing.T) { ...@@ -493,8 +493,13 @@ func TestCompileCommands(t *testing.T) {
require.Zero(t, exitCode, "exit code") require.Zero(t, exitCode, "exit code")
require.Contains(t, string(d), "Sketch created") require.Contains(t, string(d), "Sketch created")
// Build sketch for arduino:avr:uno // Build sketch without FQBN
test1 := currSketchbookDir.Join("Test1").String() test1 := currSketchbookDir.Join("Test1").String()
exitCode, d = executeWithArgs(t, "compile", test1)
require.NotZero(t, exitCode, "exit code")
require.Contains(t, string(d), "No Fully Qualified Board Name provided")
// Build sketch for arduino:avr:uno
exitCode, d = executeWithArgs(t, "compile", "-b", "arduino:avr:uno", test1) exitCode, d = executeWithArgs(t, "compile", "-b", "arduino:avr:uno", test1)
require.Zero(t, exitCode, "exit code") require.Zero(t, exitCode, "exit code")
require.Contains(t, string(d), "Sketch uses") require.Contains(t, string(d), "Sketch uses")
......
...@@ -31,7 +31,7 @@ import ( ...@@ -31,7 +31,7 @@ import (
"github.com/arduino/arduino-cli/commands" "github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/core" "github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter" "github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/go-paths-helper" paths "github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap" properties "github.com/arduino/go-properties-orderedmap"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -109,7 +109,7 @@ func run(cmd *cobra.Command, args []string) { ...@@ -109,7 +109,7 @@ func run(cmd *cobra.Command, args []string) {
os.Exit(commands.ErrGeneric) os.Exit(commands.ErrGeneric)
} }
if flags.fqbn == "" && sketch != nil { if flags.fqbn == "" && sketch != nil && sketch.Metadata != nil {
flags.fqbn = sketch.Metadata.CPU.Fqbn flags.fqbn = sketch.Metadata.CPU.Fqbn
} }
if flags.fqbn == "" { if flags.fqbn == "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment