Skip to content

Commit b13a29c

Browse files
committed
Add integration test for tool removal during platform uninstall
Tool dependency by `arduino-cli core uninstall` is somewhat complex because it must only uninstall the tools that no other platforms have a dependency on. If it doesn't, it breaks the other platform and the cause of this breakage would likely not be obvious to the user. So it's important to test to ensure this functionality continues to work correctly.
1 parent e335dff commit b13a29c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/test_core.py

+43
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,49 @@ def test_core_uninstall(run_command):
205205
assert not _in(result.stdout, "arduino:avr")
206206

207207

208+
def test_core_uninstall_tool_dependency_removal(run_command):
209+
# These platforms both have a dependency on the arduino:[email protected] tool
210+
# arduino:[email protected] has a dependency on arduino:[email protected]
211+
assert run_command("core install arduino:[email protected]")
212+
# arduino:[email protected] has a dependency on arduino:[email protected]
213+
assert run_command("core install arduino:[email protected]")
214+
assert run_command("core uninstall arduino:avr")
215+
216+
result = run_command("config dump --format json")
217+
assert result.ok
218+
settings_json = json.loads(result.stdout)
219+
arduino_tools_path = os.path.join(
220+
settings_json["directories"]["data"],
221+
"packages",
222+
"arduino",
223+
"tools"
224+
)
225+
226+
avr_gcc_binaries_path = os.path.join(
227+
arduino_tools_path,
228+
"avr-gcc",
229+
"7.3.0-atmel3.6.1-arduino5",
230+
"bin"
231+
)
232+
# The tool arduino:[email protected] that is a dep of another installed platform should remain
233+
assert (
234+
os.path.exists(os.path.join(avr_gcc_binaries_path, "avr-gcc"))
235+
or os.path.exists(os.path.join(avr_gcc_binaries_path, "avr-gcc.exe"))
236+
)
237+
238+
avrdude_binaries_path = os.path.join(
239+
arduino_tools_path,
240+
"avrdude",
241+
"6.3.0-arduino17",
242+
"bin"
243+
)
244+
# The tool arduino:[email protected] that is only a dep of arduino:avr should have been removed
245+
assert (
246+
os.path.exists(os.path.join(avrdude_binaries_path, "avrdude"))
247+
or os.path.exists(os.path.join(avrdude_binaries_path, "avrdude.exe"))
248+
) is False
249+
250+
208251
def test_core_zipslip(run_command):
209252
url = "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/test_index.json"
210253
assert run_command("core update-index --additional-urls={}".format(url))

0 commit comments

Comments
 (0)