@@ -159,7 +159,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
159
159
160
160
161
161
@pytest .mark .skipif (running_on_ci (), reason = "VMs have no serial ports" )
162
- def test_compile_and_compile_combo (run_command , data_dir ):
162
+ def test_compile_and_compile_combo (run_command , data_dir , detected_boards ):
163
163
# Init the environment explicitly
164
164
result = run_command ("core update-index" )
165
165
assert result .ok
@@ -176,58 +176,17 @@ def test_compile_and_compile_combo(run_command, data_dir):
176
176
assert result .ok
177
177
assert "Sketch created in: {}" .format (sketch_path ) in result .stdout
178
178
179
- #
180
- # Build a list of detected boards to test, if any.
181
- #
182
- result = run_command ("board list --format json" )
183
- assert result .ok
184
-
185
- #
186
- # The `board list --format json` returns a JSON that looks like to the following:
187
- #
188
- # [
189
- # {
190
- # "address": "/dev/cu.usbmodem14201",
191
- # "protocol": "serial",
192
- # "protocol_label": "Serial Port (USB)",
193
- # "boards": [
194
- # {
195
- # "name": "Arduino NANO 33 IoT",
196
- # "FQBN": "arduino:samd:nano_33_iot"
197
- # }
198
- # ]
199
- # }
200
- # ]
201
-
202
- detected_boards = []
203
-
204
- ports = json .loads (result .stdout )
205
- assert isinstance (ports , list )
206
- for port in ports :
207
- boards = port .get ("boards" )
208
- if boards is None :
209
- continue
210
- assert isinstance (boards , list )
211
- for board in boards :
212
- detected_boards .append (
213
- dict (address = port .get ("address" ), fqbn = board .get ("FQBN" ))
214
- )
215
-
216
- assert len (detected_boards ) >= 1 , "There are no boards available for testing"
217
-
218
179
# Build sketch for each detected board
219
180
for board in detected_boards :
220
- log_file_name = "{fqbn}-compile.log" .format (
221
- fqbn = board .get ("fqbn" ).replace (":" , "-" )
222
- )
181
+ log_file_name = "{fqbn}-compile.log" .format (fqbn = board .fqbn .replace (":" , "-" ))
223
182
log_file_path = os .path .join (data_dir , log_file_name )
224
183
command_log_flags = "--log-format json --log-file {} --log-level trace" .format (
225
184
log_file_path
226
185
)
227
186
result = run_command (
228
187
"compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
229
- fqbn = board .get ( " fqbn" ) ,
230
- address = board .get ( " address" ) ,
188
+ fqbn = board .fqbn ,
189
+ address = board .address ,
231
190
sketch_path = sketch_path ,
232
191
log_flags = command_log_flags ,
233
192
)
@@ -238,16 +197,16 @@ def test_compile_and_compile_combo(run_command, data_dir):
238
197
json_log_lines = log_json .readlines ()
239
198
expected_trace_sequence = [
240
199
"Compile {sketch} for {fqbn} started" .format (
241
- sketch = sketch_path , fqbn = board .get ( " fqbn" )
200
+ sketch = sketch_path , fqbn = board .fqbn
242
201
),
243
202
"Compile {sketch} for {fqbn} successful" .format (
244
- sketch = sketch_name , fqbn = board .get ( " fqbn" )
203
+ sketch = sketch_name , fqbn = board .fqbn
245
204
),
246
205
"Upload {sketch} on {fqbn} started" .format (
247
- sketch = sketch_path , fqbn = board .get ( " fqbn" )
206
+ sketch = sketch_path , fqbn = board .fqbn
248
207
),
249
208
"Upload {sketch} on {fqbn} successful" .format (
250
- sketch = sketch_name , fqbn = board .get ( " fqbn" )
209
+ sketch = sketch_name , fqbn = board .fqbn
251
210
),
252
211
]
253
212
assert is_message_sequence_in_json_log_traces (
0 commit comments