Skip to content

Commit 18a4039

Browse files
Migrate TestUploadSketchWithMismatchedCasing from test_upload.py to upload_test.go
1 parent b13ed89 commit 18a4039

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

internal/integrationtest/upload/upload_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,36 @@ func TestCompileAndUploadComboSketchWithMismatchedCasing(t *testing.T) {
492492
require.Contains(t, string(stderr), "Error opening sketch:")
493493
}
494494
}
495+
496+
func TestUploadSketchWithMismatchedCasing(t *testing.T) {
497+
if os.Getenv("CI") != "" {
498+
t.Skip("VMs have no serial ports")
499+
}
500+
501+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
502+
defer env.CleanUp()
503+
504+
_, _, err := cli.Run("update")
505+
require.NoError(t, err)
506+
507+
// Create a sketch
508+
sketchName := "UploadMismatchCasing"
509+
sketchPath := cli.SketchbookDir().Join(sketchName)
510+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
511+
require.NoError(t, err)
512+
513+
// Rename main .ino file so casing is different from sketch name
514+
require.NoError(t, sketchPath.Join(sketchName+".ino").Rename(sketchPath.Join(strings.ToLower(sketchName)+".ino")))
515+
516+
for _, board := range detectedBoards(t, cli) {
517+
// Install core
518+
_, _, err = cli.Run("core", "install", board.core)
519+
require.NoError(t, err)
520+
521+
// Tries to upload given sketch, it has not been compiled but it fails even before
522+
// searching for binaries since the sketch is not valid
523+
_, stderr, err := cli.Run("upload", "-b", board.fqbn, "-p", board.address, sketchPath.String())
524+
require.Error(t, err)
525+
require.Contains(t, string(stderr), "Error during Upload:")
526+
}
527+
}

test/test_upload.py

-23
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,6 @@ def test_upload_after_attach(run_command, data_dir, detected_boards):
4242
assert run_command(["upload", sketch_path])
4343

4444

45-
def test_upload_sketch_with_mismatched_casing(run_command, data_dir, detected_boards, wait_for_board):
46-
assert run_command(["update"])
47-
48-
# Create a sketch
49-
sketch_name = "UploadMismatchCasing"
50-
sketch_path = Path(data_dir, sketch_name)
51-
assert run_command(["sketch", "new", sketch_path])
52-
53-
# Rename main .ino file so casing is different from sketch name
54-
Path(sketch_path, f"{sketch_name}.ino").rename(sketch_path / f"{sketch_name.lower()}.ino")
55-
56-
for board in detected_boards:
57-
# Install core
58-
core = ":".join(board.fqbn.split(":")[:2])
59-
assert run_command(["core", "install", core])
60-
61-
# Tries to upload given sketch, it has not been compiled but it fails even before
62-
# searching for binaries since the sketch is not valid
63-
res = run_command(["upload", "-b", board.fqbn, "-p", board.address, sketch_path])
64-
assert res.failed
65-
assert "Error during Upload:" in res.stderr
66-
67-
6845
def test_upload_to_port_with_board_autodetect(run_command, data_dir, detected_boards):
6946
assert run_command(["update"])
7047

0 commit comments

Comments
 (0)