From a248c3b1ec9a90b4f8f886de6afbfda28da854fb Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Fri, 19 Nov 2021 18:42:11 +0100 Subject: [PATCH 1/3] fix a regression introduced in be5022e07cdfa9398c9fc035b8605009193f4f81. `--input` flags were ignored partially revert "refactor sketch path calculation" in `upload.go` --- cli/upload/upload.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cli/upload/upload.go b/cli/upload/upload.go index 670f0847a5e..7b77a4e413e 100644 --- a/cli/upload/upload.go +++ b/cli/upload/upload.go @@ -19,6 +19,7 @@ import ( "context" "os" + "github.com/arduino/arduino-cli/arduino/sketch" "github.com/arduino/arduino-cli/cli/arguments" "github.com/arduino/arduino-cli/cli/errorcodes" "github.com/arduino/arduino-cli/cli/feedback" @@ -76,10 +77,27 @@ func runUploadCommand(command *cobra.Command, args []string) { if len(args) > 0 { path = args[0] } - sketchPath := arguments.InitSketchPath(path) - sk := arguments.NewSketch(sketchPath) - discoveryPort := port.GetDiscoveryPort(instance, sk) + + // .pde files are still supported but deprecated, this warning urges the user to rename them + if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 && importDir == "" && importFile == "" { + feedback.Error(tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:")) + for _, f := range files { + feedback.Error(f) + } + } + + 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 the user didn't specify an FQBN and a sketch.json file is present From 8632870cd86d9d974f333d4c6972dc0c5314b9e6 Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Fri, 19 Nov 2021 18:42:11 +0100 Subject: [PATCH 2/3] fix test after f85513c66ca8b8ad1d089ac1f067638bc21cedab --- test/test_upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_upload.py b/test/test_upload.py index cf1933b84bf..2edc9ec7e8b 100644 --- a/test/test_upload.py +++ b/test/test_upload.py @@ -111,7 +111,7 @@ def test_upload_after_attach(run_command, data_dir, detected_boards): # Create a sketch sketch_path = os.path.join(data_dir, "foo") 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 assert run_command(["compile", sketch_path]) # Upload From df7596e0f436cd6f5e797e6985731597f832a2eb Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Fri, 19 Nov 2021 18:42:11 +0100 Subject: [PATCH 3/3] use `WarnDeprecatedFiles` to remove some code duplication --- cli/upload/upload.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cli/upload/upload.go b/cli/upload/upload.go index 7b77a4e413e..3580ba2ade2 100644 --- a/cli/upload/upload.go +++ b/cli/upload/upload.go @@ -79,12 +79,8 @@ func runUploadCommand(command *cobra.Command, args []string) { } sketchPath := arguments.InitSketchPath(path) - // .pde files are still supported but deprecated, this warning urges the user to rename them - if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 && importDir == "" && importFile == "" { - feedback.Error(tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:")) - for _, f := range files { - feedback.Error(f) - } + if importDir == "" && importFile == "" { + arguments.WarnDeprecatedFiles(sketchPath) } sk, err := sketch.New(sketchPath)