@@ -57,17 +57,21 @@ def test_compile_with_simple_sketch(run_command, data_dir):
57
57
log_file_path = os .path .join (data_dir , log_file_name )
58
58
result = run_command (
59
59
"compile -b {fqbn} {sketch_path} --log-format json --log-file {log_file} --log-level trace" .format (
60
- fqbn = fqbn , sketch_path = sketch_path , log_file = log_file_path ))
60
+ fqbn = fqbn , sketch_path = sketch_path , log_file = log_file_path
61
+ )
62
+ )
61
63
assert result .ok
62
64
63
65
# let's test from the logs if the hex file produced by successful compile is moved to our sketch folder
64
- log_json = open (log_file_path , 'r' )
66
+ log_json = open (log_file_path , "r" )
65
67
json_log_lines = log_json .readlines ()
66
68
expected_trace_sequence = [
67
69
"Compile {sketch} for {fqbn} started" .format (sketch = sketch_path , fqbn = fqbn ),
68
- "Compile {sketch} for {fqbn} successful" .format (sketch = sketch_name , fqbn = fqbn )
70
+ "Compile {sketch} for {fqbn} successful" .format (sketch = sketch_name , fqbn = fqbn ),
69
71
]
70
- assert is_message_sequence_in_json_log_traces (expected_trace_sequence , json_log_lines )
72
+ assert is_message_sequence_in_json_log_traces (
73
+ expected_trace_sequence , json_log_lines
74
+ )
71
75
72
76
73
77
def test_compile_with_sketch_with_symlink_selfloop (run_command , data_dir ):
@@ -94,8 +98,8 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
94
98
95
99
# Build sketch for arduino:avr:uno
96
100
result = run_command (
97
- "compile -b {fqbn} {sketch_path}" .format (
98
- fqbn = fqbn , sketch_path = sketch_path ) )
101
+ "compile -b {fqbn} {sketch_path}" .format (fqbn = fqbn , sketch_path = sketch_path )
102
+ )
99
103
# The assertion is a bit relaxed in this case because win behaves differently from macOs and linux
100
104
# returning a different error detailed message
101
105
assert "Error during sketch processing" in result .stderr
@@ -118,8 +122,8 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
118
122
119
123
# Build sketch for arduino:avr:uno
120
124
result = run_command (
121
- "compile -b {fqbn} {sketch_path}" .format (
122
- fqbn = fqbn , sketch_path = sketch_path ) )
125
+ "compile -b {fqbn} {sketch_path}" .format (fqbn = fqbn , sketch_path = sketch_path )
126
+ )
123
127
# The assertion is a bit relaxed also in this case because macOS behaves differently from win and linux:
124
128
# the cli does not follow recursively the symlink til breaking
125
129
assert "Error during sketch processing" in result .stderr
@@ -177,32 +181,50 @@ def test_compile_and_compile_combo(run_command, data_dir):
177
181
continue
178
182
assert isinstance (boards , list )
179
183
for board in boards :
180
- detected_boards .append (dict (address = port .get ('address' ), fqbn = board .get ('FQBN' )))
184
+ detected_boards .append (
185
+ dict (address = port .get ("address" ), fqbn = board .get ("FQBN" ))
186
+ )
181
187
182
188
assert len (detected_boards ) >= 1 , "There are no boards available for testing"
183
189
184
190
# Build sketch for each detected board
185
191
for board in detected_boards :
186
- log_file_name = "{fqbn}-compile.log" .format (fqbn = board .get ('fqbn' ).replace (":" , "-" ))
192
+ log_file_name = "{fqbn}-compile.log" .format (
193
+ fqbn = board .get ("fqbn" ).replace (":" , "-" )
194
+ )
187
195
log_file_path = os .path .join (data_dir , log_file_name )
188
- command_log_flags = "--log-format json --log-file {} --log-level trace" .format (log_file_path )
189
- result = run_command ("compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
190
- fqbn = board .get ('fqbn' ),
191
- address = board .get ('address' ),
192
- sketch_path = sketch_path ,
193
- log_flags = command_log_flags
194
- ))
196
+ command_log_flags = "--log-format json --log-file {} --log-level trace" .format (
197
+ log_file_path
198
+ )
199
+ result = run_command (
200
+ "compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}" .format (
201
+ fqbn = board .get ("fqbn" ),
202
+ address = board .get ("address" ),
203
+ sketch_path = sketch_path ,
204
+ log_flags = command_log_flags ,
205
+ )
206
+ )
195
207
assert result .ok
196
208
# check from the logs if the bin file were uploaded on the current board
197
- log_json = open (log_file_path , 'r' )
209
+ log_json = open (log_file_path , "r" )
198
210
json_log_lines = log_json .readlines ()
199
211
expected_trace_sequence = [
200
- "Compile {sketch} for {fqbn} started" .format (sketch = sketch_path , fqbn = board .get ('fqbn' )),
201
- "Compile {sketch} for {fqbn} successful" .format (sketch = sketch_name , fqbn = board .get ('fqbn' )),
202
- "Upload {sketch} on {fqbn} started" .format (sketch = sketch_path , fqbn = board .get ('fqbn' )),
203
- "Upload {sketch} on {fqbn} successful" .format (sketch = sketch_name , fqbn = board .get ('fqbn' ))
212
+ "Compile {sketch} for {fqbn} started" .format (
213
+ sketch = sketch_path , fqbn = board .get ("fqbn" )
214
+ ),
215
+ "Compile {sketch} for {fqbn} successful" .format (
216
+ sketch = sketch_name , fqbn = board .get ("fqbn" )
217
+ ),
218
+ "Upload {sketch} on {fqbn} started" .format (
219
+ sketch = sketch_path , fqbn = board .get ("fqbn" )
220
+ ),
221
+ "Upload {sketch} on {fqbn} successful" .format (
222
+ sketch = sketch_name , fqbn = board .get ("fqbn" )
223
+ ),
204
224
]
205
- assert is_message_sequence_in_json_log_traces (expected_trace_sequence , json_log_lines )
225
+ assert is_message_sequence_in_json_log_traces (
226
+ expected_trace_sequence , json_log_lines
227
+ )
206
228
207
229
208
230
def is_message_sequence_in_json_log_traces (message_sequence , log_json_lines ):
@@ -213,3 +235,34 @@ def is_message_sequence_in_json_log_traces(message_sequence, log_json_lines):
213
235
if entry .get ("msg" ) in message_sequence :
214
236
trace_entries .append (entry .get ("msg" ))
215
237
return message_sequence == trace_entries
238
+
239
+
240
+ def test_compile_blacklisted_sketchname (run_command , data_dir ):
241
+ """
242
+ Compile should ignore folders named `RCS`, `.git` and the likes, but
243
+ it should be ok for a sketch to be named like RCS.ino
244
+ """
245
+ # Init the environment explicitly
246
+ result = run_command ("core update-index" )
247
+ assert result .ok
248
+
249
+ # Download latest AVR
250
+ result = run_command ("core install arduino:avr" )
251
+ assert result .ok
252
+
253
+ sketch_name = "RCS"
254
+ sketch_path = os .path .join (data_dir , sketch_name )
255
+ fqbn = "arduino:avr:uno"
256
+
257
+ # Create a test sketch
258
+ result = run_command ("sketch new {}" .format (sketch_path ))
259
+ assert result .ok
260
+ assert "Sketch created in: {}" .format (sketch_path ) in result .stdout
261
+
262
+ # Build sketch for arduino:avr:uno
263
+ log_file_name = "compile.log"
264
+ log_file_path = os .path .join (data_dir , log_file_name )
265
+ result = run_command (
266
+ "compile -b {fqbn} {sketch_path}" .format (fqbn = fqbn , sketch_path = sketch_path )
267
+ )
268
+ assert result .ok
0 commit comments