@@ -71,15 +71,7 @@ def test_compile_with_simple_sketch(run_command, data_dir):
71
71
72
72
73
73
@pytest .mark .skipif (running_on_ci (), reason = "VMs have no serial ports" )
74
- def test_compile_and_compile_combo (run_command , data_dir ):
75
- # Init the environment explicitly
76
- result = run_command ("core update-index" )
77
- assert result .ok
78
-
79
- # Install required core(s)
80
- result = run_command ("core install arduino:avr" )
81
- result = run_command ("core install arduino:samd" )
82
- assert result .ok
74
+ def test_compile_and_compile_combo (run_command , detected_boards , data_dir ):
83
75
84
76
# Create a test sketch
85
77
sketch_name = "CompileAndUploadIntegrationTest"
@@ -88,49 +80,23 @@ def test_compile_and_compile_combo(run_command, data_dir):
88
80
assert result .ok
89
81
assert "Sketch created in: {}" .format (sketch_path ) in result .stdout
90
82
91
- #
92
- # Build a list of detected boards to test, if any.
93
- #
94
- result = run_command ("board list --format json" )
95
- assert result .ok
96
-
97
- #
98
- # The `board list --format json` returns a JSON that looks like to the following:
99
- #
100
- # [
101
- # {
102
- # "address": "/dev/cu.usbmodem14201",
103
- # "protocol": "serial",
104
- # "protocol_label": "Serial Port (USB)",
105
- # "boards": [
106
- # {
107
- # "name": "Arduino NANO 33 IoT",
108
- # "FQBN": "arduino:samd:nano_33_iot"
109
- # }
110
- # ]
111
- # }
112
- # ]
113
-
114
- detected_boards = []
115
-
116
- ports = json .loads (result .stdout )
117
- assert isinstance (ports , list )
118
- for port in ports :
119
- boards = port .get ('boards' )
120
- assert isinstance (boards , list )
121
- for board in boards :
122
- detected_boards .append (dict (address = port .get ('address' ), fqbn = board .get ('FQBN' )))
123
-
124
- assert len (detected_boards ) >= 1 , "There are no boards available for testing"
125
-
126
83
# Build sketch for each detected board
127
84
for board in detected_boards :
128
- log_file_name = "{fqbn}-compile.log" .format (fqbn = board .get ('fqbn' ).replace (":" , "-" ))
85
+
86
+ # Init the environment explicitly
87
+ result = run_command ("core update-index" )
88
+ assert result .ok
89
+
90
+ # Install required core(s)
91
+ result = run_command ("core install {}" .format (board .core ))
92
+ assert result .ok
93
+
94
+ log_file_name = "{fqbn}-compile.log" .format (fqbn = board .fqbn .replace (":" , "-" ))
129
95
log_file_path = os .path .join (data_dir , log_file_name )
130
96
command_log_flags = "--log-format json --log-file {} --log-level trace" .format (log_file_path )
131
97
result = run_command ("compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
132
- fqbn = board .get ( ' fqbn' ) ,
133
- address = board .get ( ' address' ) ,
98
+ fqbn = board .fqbn ,
99
+ address = board .address ,
134
100
sketch_path = sketch_path ,
135
101
log_flags = command_log_flags
136
102
))
@@ -139,10 +105,10 @@ def test_compile_and_compile_combo(run_command, data_dir):
139
105
log_json = open (log_file_path , 'r' )
140
106
json_log_lines = log_json .readlines ()
141
107
expected_trace_sequence = [
142
- "Compile {sketch} for {fqbn} started" .format (sketch = sketch_path , fqbn = board .get ( ' fqbn' ) ),
143
- "Compile {sketch} for {fqbn} successful" .format (sketch = sketch_name , fqbn = board .get ( ' fqbn' ) ),
144
- "Upload {sketch} on {fqbn} started" .format (sketch = sketch_path , fqbn = board .get ( ' fqbn' ) ),
145
- "Upload {sketch} on {fqbn} successful" .format (sketch = sketch_name , fqbn = board .get ( ' fqbn' ) )
108
+ "Compile {sketch} for {fqbn} started" .format (sketch = sketch_path , fqbn = board .fqbn ),
109
+ "Compile {sketch} for {fqbn} successful" .format (sketch = sketch_name , fqbn = board .fqbn ),
110
+ "Upload {sketch} on {fqbn} started" .format (sketch = sketch_path , fqbn = board .fqbn ),
111
+ "Upload {sketch} on {fqbn} successful" .format (sketch = sketch_name , fqbn = board .fqbn )
146
112
]
147
113
assert is_message_sequence_in_json_log_traces (expected_trace_sequence , json_log_lines )
148
114
0 commit comments