@@ -180,7 +180,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
180
180
181
181
182
182
@pytest .mark .skipif (running_on_ci (), reason = "VMs have no serial ports" )
183
- def test_compile_and_compile_combo (run_command , data_dir , detected_boards ):
183
+ def test_compile_and_upload_combo (run_command , data_dir , detected_boards ):
184
184
# Init the environment explicitly
185
185
result = run_command ("core update-index" )
186
186
assert result .ok
@@ -193,6 +193,7 @@ def test_compile_and_compile_combo(run_command, data_dir, detected_boards):
193
193
# Create a test sketch
194
194
sketch_name = "CompileAndUploadIntegrationTest"
195
195
sketch_path = os .path .join (data_dir , sketch_name )
196
+ sketch_main_file = os .path .join (sketch_path , sketch_name + ".ino" )
196
197
result = run_command ("sketch new {}" .format (sketch_path ))
197
198
assert result .ok
198
199
assert "Sketch created in: {}" .format (sketch_path ) in result .stdout
@@ -204,35 +205,41 @@ def test_compile_and_compile_combo(run_command, data_dir, detected_boards):
204
205
command_log_flags = "--log-format json --log-file {} --log-level trace" .format (
205
206
log_file_path
206
207
)
207
- result = run_command (
208
- "compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
209
- fqbn = board .fqbn ,
210
- address = board .address ,
211
- sketch_path = sketch_path ,
212
- log_flags = command_log_flags ,
208
+
209
+ def run_test (s ):
210
+ result = run_command (
211
+ "compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
212
+ fqbn = board .fqbn ,
213
+ address = board .address ,
214
+ sketch_path = s ,
215
+ log_flags = command_log_flags ,
216
+ )
213
217
)
214
- )
215
- assert result .ok
216
- # check from the logs if the bin file were uploaded on the current board
217
- log_json = open (log_file_path , "r" )
218
- json_log_lines = log_json .readlines ()
219
- expected_trace_sequence = [
220
- "Compile {sketch} for {fqbn} started" .format (
221
- sketch = sketch_path , fqbn = board .fqbn
222
- ),
223
- "Compile {sketch} for {fqbn} successful" .format (
224
- sketch = sketch_name , fqbn = board .fqbn
225
- ),
226
- "Upload {sketch} on {fqbn} started" .format (
227
- sketch = sketch_path , fqbn = board .fqbn
228
- ),
229
- "Upload {sketch} on {fqbn} successful" .format (
230
- sketch = sketch_name , fqbn = board .fqbn
231
- ),
232
- ]
233
- assert is_message_sequence_in_json_log_traces (
234
- expected_trace_sequence , json_log_lines
235
- )
218
+ assert result .ok
219
+
220
+ # check from the logs if the bin file were uploaded on the current board
221
+ log_json = open (log_file_path , "r" )
222
+ json_log_lines = log_json .readlines ()
223
+ expected_trace_sequence = [
224
+ "Compile {sketch} for {fqbn} started" .format (
225
+ sketch = sketch_path , fqbn = board .fqbn
226
+ ),
227
+ "Compile {sketch} for {fqbn} successful" .format (
228
+ sketch = sketch_name , fqbn = board .fqbn
229
+ ),
230
+ "Upload {sketch} on {fqbn} started" .format (
231
+ sketch = sketch_path , fqbn = board .fqbn
232
+ ),
233
+ "Upload {sketch} on {fqbn} successful" .format (
234
+ sketch = sketch_name , fqbn = board .fqbn
235
+ ),
236
+ ]
237
+ assert is_message_sequence_in_json_log_traces (
238
+ expected_trace_sequence , json_log_lines
239
+ )
240
+
241
+ run_test (sketch_path )
242
+ run_test (sketch_main_file )
236
243
237
244
238
245
def is_message_sequence_in_json_log_traces (message_sequence , log_json_lines ):
0 commit comments