Skip to content

Commit 6685633

Browse files
committed
Add more upload mock integration tests
1 parent b59b6f6 commit 6685633

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

test/test_upload_mock.py

+51-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def generate_build_dir(sketch_path):
2828

2929
testdata = [
3030
(
31+
"",
3132
"arduino:avr:uno",
3233
"arduino:avr@1.8.3",
3334
"/dev/ttyACM0",
@@ -36,23 +37,71 @@ def generate_build_dir(sketch_path):
3637
+ '-v -V -patmega328p -carduino "-P{upload_port}" -b115200 -D "-Uflash:w:{build_dir}/{sketch_name}.ino.hex:i"',
3738
),
3839
(
40+
"",
3941
"arduino:avr:leonardo",
4042
"arduino:avr@1.8.3",
4143
"/dev/ttyACM999",
4244
'"{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" '
4345
+ '"-C{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" '
4446
+ '-v -V -patmega32u4 -cavr109 "-P{upload_port}0" -b57600 -D "-Uflash:w:{build_dir}/{sketch_name}.ino.hex:i"',
4547
),
48+
(
49+
"https://adafruit.github.io/arduino-board-index/package_adafruit_index.json",
50+
"adafruit:avr:flora8",
51+
"adafruit:avr@1.4.13",
52+
"/dev/ttyACM0",
53+
'"{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" '
54+
+ '"-C{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" '
55+
+ '-v -patmega32u4 -cavr109 -P{upload_port} -b57600 -D "-Uflash:w:{build_dir}/{sketch_name}.ino.hex:i"',
56+
),
57+
(
58+
"https://adafruit.github.io/arduino-board-index/package_adafruit_index.json",
59+
"adafruit:avr:flora8",
60+
"adafruit:avr@1.4.13",
61+
"/dev/ttyACM999",
62+
'"{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" '
63+
+ '"-C{data_dir}/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" '
64+
+ '-v -patmega32u4 -cavr109 -P{upload_port}0 -b57600 -D "-Uflash:w:{build_dir}/{sketch_name}.ino.hex:i"',
65+
),
66+
(
67+
"https://dl.espressif.com/dl/package_esp32_index.json",
68+
"esp32:esp32:esp32thing",
69+
"esp32:esp32@1.0.6",
70+
"/dev/ttyACM0",
71+
'python "{data_dir}/packages/esp32/tools/esptool_py/3.0.0/esptool.py" '
72+
+ '--chip esp32 --port "{upload_port}" --baud 921600 --before default_reset '
73+
+ "--after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 "
74+
+ '"{data_dir}/packages/esp32/hardware/esp32/1.0.6/tools/partitions/boot_app0.bin" 0x1000 '
75+
+ '"{data_dir}/packages/esp32/hardware/esp32/1.0.6/tools/sdk/bin/bootloader_dio_80m.bin" 0x10000 '
76+
+ '"{build_dir}/{sketch_name}.ino.bin" 0x8000 "{build_dir}/{sketch_name}.ino.partitions.bin"',
77+
),
78+
(
79+
"http://arduino.esp8266.com/stable/package_esp8266com_index.json",
80+
"esp8266:esp8266:generic",
81+
"esp8266:esp8266@3.0.1",
82+
"/dev/ttyACM0",
83+
'"{data_dir}/packages/esp8266/tools/python3/3.7.2-post1/python3" '
84+
+ '"{data_dir}/packages/esp8266/hardware/esp8266/3.0.1/tools/upload.py" '
85+
+ '--chip esp8266 --port "{upload_port}" --baud "115200" "" '
86+
+ "--before default_reset --after hard_reset write_flash 0x0 "
87+
+ '"{build_dir}/{sketch_name}.ino.bin"',
88+
),
4689
]
4790

4891

49-
@pytest.mark.parametrize("fqbn, core, upload_port, expected_output", testdata)
50-
def test_upload_sketch(run_command, session_data_dir, downloads_dir, fqbn, core, upload_port, expected_output):
92+
@pytest.mark.parametrize("index, fqbn, core, upload_port, expected_output", testdata)
93+
def test_upload_sketch(run_command, session_data_dir, downloads_dir, index, fqbn, core, upload_port, expected_output):
5194
env = {
5295
"ARDUINO_DATA_DIR": session_data_dir,
5396
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
5497
"ARDUINO_SKETCHBOOK_DIR": session_data_dir,
5598
}
99+
100+
if index:
101+
assert run_command("config init --overwrite", custom_env=env)
102+
assert run_command(f"config add board_manager.additional_urls {index}", custom_env=env)
103+
assert run_command("update", custom_env=env)
104+
56105
assert run_command(f"core install {core}", custom_env=env)
57106

58107
# Create a sketch

0 commit comments

Comments
 (0)