Commit 750e9142 authored by Umberto Baldi's avatar Umberto Baldi Committed by Umberto Baldi

fix a regression introduced in #be5022e0. `--input` flags were ignored (#1558)

* fix a regression introduced in be5022e0. `--input` flags were ignored
partially revert "refactor sketch path calculation" in `upload.go`

* fix test after f85513c6

* use `WarnDeprecatedFiles` to remove some code duplication
parent eff632ca
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"context" "context"
"os" "os"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/cli/arguments" "github.com/arduino/arduino-cli/cli/arguments"
"github.com/arduino/arduino-cli/cli/errorcodes" "github.com/arduino/arduino-cli/cli/errorcodes"
"github.com/arduino/arduino-cli/cli/feedback" "github.com/arduino/arduino-cli/cli/feedback"
...@@ -76,10 +77,23 @@ func runUploadCommand(command *cobra.Command, args []string) { ...@@ -76,10 +77,23 @@ func runUploadCommand(command *cobra.Command, args []string) {
if len(args) > 0 { if len(args) > 0 {
path = args[0] path = args[0]
} }
sketchPath := arguments.InitSketchPath(path) sketchPath := arguments.InitSketchPath(path)
sk := arguments.NewSketch(sketchPath)
discoveryPort := port.GetDiscoveryPort(instance, sk) if importDir == "" && importFile == "" {
arguments.WarnDeprecatedFiles(sketchPath)
}
sk, err := sketch.New(sketchPath)
if err != nil && importDir == "" && importFile == "" {
feedback.Errorf(tr("Error during Upload: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
discoveryPort, err := port.GetPort(instance, sk)
if err != nil {
feedback.Errorf(tr("Error during Upload: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
if fqbn.String() == "" && sk != nil && sk.Metadata != nil { if fqbn.String() == "" && sk != nil && sk.Metadata != nil {
// If the user didn't specify an FQBN and a sketch.json file is present // If the user didn't specify an FQBN and a sketch.json file is present
......
...@@ -111,7 +111,7 @@ def test_upload_after_attach(run_command, data_dir, detected_boards): ...@@ -111,7 +111,7 @@ def test_upload_after_attach(run_command, data_dir, detected_boards):
# Create a sketch # Create a sketch
sketch_path = os.path.join(data_dir, "foo") sketch_path = os.path.join(data_dir, "foo")
assert run_command(["sketch", "new", sketch_path]) assert run_command(["sketch", "new", sketch_path])
assert run_command(["board", "attach", f"serial://{board.address}", sketch_path]) assert run_command(["board", "attach", "-p", board.address, sketch_path])
# Build sketch # Build sketch
assert run_command(["compile", sketch_path]) assert run_command(["compile", sketch_path])
# Upload # Upload
......
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