|
16 | 16 | package compile_part_1_test
|
17 | 17 |
|
18 | 18 | import (
|
| 19 | + "strings" |
19 | 20 | "testing"
|
20 | 21 |
|
21 | 22 | "github.com/arduino/arduino-cli/internal/integrationtest"
|
@@ -101,3 +102,44 @@ func TestCompileSketchWithMultipleMainFiles(t *testing.T) {
|
101 | 102 | require.Error(t, err)
|
102 | 103 | require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found")
|
103 | 104 | }
|
| 105 | + |
| 106 | +func TestCompileSketchCaseMismatchFails(t *testing.T) { |
| 107 | + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
| 108 | + defer env.CleanUp() |
| 109 | + |
| 110 | + // Init the environment explicitly |
| 111 | + _, _, err := cli.Run("update") |
| 112 | + require.NoError(t, err) |
| 113 | + |
| 114 | + // Install core to compile |
| 115 | + _, _, err = cli. Run( "core", "install", "arduino:[email protected]") |
| 116 | + require.NoError(t, err) |
| 117 | + |
| 118 | + sketchName := "CompileSketchCaseMismatch" |
| 119 | + sketchPath := cli.SketchbookDir().Join(sketchName) |
| 120 | + fqbn := "arduino:avr:uno" |
| 121 | + |
| 122 | + _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
| 123 | + require.NoError(t, err) |
| 124 | + |
| 125 | + // Rename main .ino file so casing is different from sketch name |
| 126 | + sketchFile := sketchPath.Join(sketchName + ".ino") |
| 127 | + sketchMainFile := sketchPath.Join(strings.ToLower(sketchName) + ".ino") |
| 128 | + err = sketchFile.Rename(sketchMainFile) |
| 129 | + require.NoError(t, err) |
| 130 | + |
| 131 | + // Verifies compilation fails when: |
| 132 | + // * Compiling with sketch path |
| 133 | + _, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) |
| 134 | + require.Error(t, err) |
| 135 | + require.Contains(t, string(stderr), "Error opening sketch:") |
| 136 | + // * Compiling with sketch main file |
| 137 | + _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchMainFile.String()) |
| 138 | + require.Error(t, err) |
| 139 | + require.Contains(t, string(stderr), "Error opening sketch:") |
| 140 | + // * Compiling in sketch path |
| 141 | + cli.SetWorkingDir(sketchPath) |
| 142 | + _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn) |
| 143 | + require.Error(t, err) |
| 144 | + require.Contains(t, string(stderr), "Error opening sketch:") |
| 145 | +} |
0 commit comments