|
16 | 16 | package compile_test |
17 | 17 |
|
18 | 18 | import ( |
19 | | - "strings" |
20 | 19 | "testing" |
21 | 20 |
|
22 | 21 | "github.com/arduino/arduino-cli/internal/integrationtest" |
@@ -62,167 +61,6 @@ func TestCompileWithFullyPrecompiledLibrary(t *testing.T) { |
62 | 61 | require.Contains(t, string(stdout), "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite") |
63 | 62 | } |
64 | 63 |
|
65 | | -func TestCompileSketchWithPdeExtension(t *testing.T) { |
66 | | - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
67 | | - defer env.CleanUp() |
68 | | - |
69 | | - // Init the environment explicitly |
70 | | - _, _, err := cli.Run("update") |
71 | | - require.NoError(t, err) |
72 | | - |
73 | | - // Install core to compile |
74 | | - _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") |
75 | | - require.NoError(t, err) |
76 | | - |
77 | | - sketchName := "CompilePdeSketch" |
78 | | - sketchPath := cli.SketchbookDir().Join(sketchName) |
79 | | - fqbn := "arduino:avr:uno" |
80 | | - |
81 | | - // Create a test sketch |
82 | | - _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
83 | | - require.NoError(t, err) |
84 | | - |
85 | | - sketchFileIno := sketchPath.Join(sketchName + ".ino") |
86 | | - sketchFilePde := sketchPath.Join(sketchName + ".pde") |
87 | | - err = sketchFileIno.Rename(sketchFilePde) |
88 | | - require.NoError(t, err) |
89 | | - |
90 | | - // Build sketch from folder |
91 | | - _, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) |
92 | | - require.NoError(t, err) |
93 | | - require.Contains(t, string(stderr), "Sketches with .pde extension are deprecated, please rename the following files to .ino:") |
94 | | - require.Contains(t, string(stderr), sketchFilePde.String()) |
95 | | - |
96 | | - // Build sketch from file |
97 | | - _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchFilePde.String()) |
98 | | - require.NoError(t, err) |
99 | | - require.Contains(t, string(stderr), "Sketches with .pde extension are deprecated, please rename the following files to .ino:") |
100 | | - require.Contains(t, string(stderr), sketchFilePde.String()) |
101 | | -} |
102 | | - |
103 | | -func TestCompileSketchWithMultipleMainFiles(t *testing.T) { |
104 | | - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
105 | | - defer env.CleanUp() |
106 | | - |
107 | | - // Init the environment explicitly |
108 | | - _, _, err := cli.Run("update") |
109 | | - require.NoError(t, err) |
110 | | - |
111 | | - // Install core to compile |
112 | | - _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") |
113 | | - require.NoError(t, err) |
114 | | - |
115 | | - sketchName := "CompileSketchMultipleMainFiles" |
116 | | - sketchPath := cli.SketchbookDir().Join(sketchName) |
117 | | - fqbn := "arduino:avr:uno" |
118 | | - |
119 | | - // Create a test sketch |
120 | | - _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
121 | | - require.NoError(t, err) |
122 | | - |
123 | | - // Copy .ino sketch file to .pde |
124 | | - sketchFileIno := sketchPath.Join(sketchName + ".ino") |
125 | | - sketchFilePde := sketchPath.Join(sketchName + ".pde") |
126 | | - err = sketchFileIno.CopyTo(sketchFilePde) |
127 | | - require.NoError(t, err) |
128 | | - |
129 | | - // Build sketch from folder |
130 | | - _, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) |
131 | | - require.Error(t, err) |
132 | | - require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found") |
133 | | - |
134 | | - // Build sketch from .ino file |
135 | | - _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchFileIno.String()) |
136 | | - require.Error(t, err) |
137 | | - require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found") |
138 | | - |
139 | | - // Build sketch from .pde file |
140 | | - _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchFilePde.String()) |
141 | | - require.Error(t, err) |
142 | | - require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found") |
143 | | -} |
144 | | - |
145 | | -func TestCompileSketchCaseMismatchFails(t *testing.T) { |
146 | | - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
147 | | - defer env.CleanUp() |
148 | | - |
149 | | - // Init the environment explicitly |
150 | | - _, _, err := cli.Run("update") |
151 | | - require.NoError(t, err) |
152 | | - |
153 | | - // Install core to compile |
154 | | - _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") |
155 | | - require.NoError(t, err) |
156 | | - |
157 | | - sketchName := "CompileSketchCaseMismatch" |
158 | | - sketchPath := cli.SketchbookDir().Join(sketchName) |
159 | | - fqbn := "arduino:avr:uno" |
160 | | - |
161 | | - _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
162 | | - require.NoError(t, err) |
163 | | - |
164 | | - // Rename main .ino file so casing is different from sketch name |
165 | | - sketchFile := sketchPath.Join(sketchName + ".ino") |
166 | | - sketchMainFile := sketchPath.Join(strings.ToLower(sketchName) + ".ino") |
167 | | - err = sketchFile.Rename(sketchMainFile) |
168 | | - require.NoError(t, err) |
169 | | - |
170 | | - // Verifies compilation fails when: |
171 | | - // * Compiling with sketch path |
172 | | - _, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) |
173 | | - require.Error(t, err) |
174 | | - require.Contains(t, string(stderr), "Error opening sketch:") |
175 | | - // * Compiling with sketch main file |
176 | | - _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchMainFile.String()) |
177 | | - require.Error(t, err) |
178 | | - require.Contains(t, string(stderr), "Error opening sketch:") |
179 | | - // * Compiling in sketch path |
180 | | - cli.SetWorkingDir(sketchPath) |
181 | | - _, stderr, err = cli.Run("compile", "--clean", "-b", fqbn) |
182 | | - require.Error(t, err) |
183 | | - require.Contains(t, string(stderr), "Error opening sketch:") |
184 | | -} |
185 | | - |
186 | | -func TestCompileWithOnlyCompilationDatabaseFlag(t *testing.T) { |
187 | | - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
188 | | - defer env.CleanUp() |
189 | | - |
190 | | - _, _, err := cli.Run("update") |
191 | | - require.NoError(t, err) |
192 | | - |
193 | | - _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") |
194 | | - require.NoError(t, err) |
195 | | - |
196 | | - sketchName := "CompileSketchOnlyCompilationDatabaseFlag" |
197 | | - sketchPath := cli.SketchbookDir().Join(sketchName) |
198 | | - fqbn := "arduino:avr:uno" |
199 | | - |
200 | | - _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
201 | | - require.NoError(t, err) |
202 | | - |
203 | | - // Verifies no binaries exist |
204 | | - buildPath := sketchPath.Join("build") |
205 | | - require.NoDirExists(t, buildPath.String()) |
206 | | - |
207 | | - // Compile with both --export-binaries and --only-compilation-database flags |
208 | | - _, _, err = cli.Run("compile", "--export-binaries", "--only-compilation-database", "--clean", "-b", fqbn, sketchPath.String()) |
209 | | - require.NoError(t, err) |
210 | | - |
211 | | - // Verifies no binaries are exported |
212 | | - require.NoDirExists(t, buildPath.String()) |
213 | | - |
214 | | - // Verifies no binaries exist |
215 | | - buildPath = cli.SketchbookDir().Join("export-dir") |
216 | | - require.NoDirExists(t, buildPath.String()) |
217 | | - |
218 | | - // Compile by setting the --output-dir flag and --only-compilation-database flags |
219 | | - _, _, err = cli.Run("compile", "--output-dir", buildPath.String(), "--only-compilation-database", "--clean", "-b", fqbn, sketchPath.String()) |
220 | | - require.NoError(t, err) |
221 | | - |
222 | | - // Verifies no binaries are exported |
223 | | - require.NoDirExists(t, buildPath.String()) |
224 | | -} |
225 | | - |
226 | 64 | func TestCompileUsingPlatformLocalTxt(t *testing.T) { |
227 | 65 | env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
228 | 66 | defer env.CleanUp() |
|
0 commit comments