Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b13a29c

Browse files
committedOct 12, 2020
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

Lines changed: 43 additions & 0 deletions
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:avr-gcc@7.3.0-atmel3.6.1-arduino5 tool
210+
# arduino:avr@1.8.2 has a dependency on arduino:avrdude@6.3.0-arduino17
211+
assert run_command("core install arduino:avr@1.8.2")
212+
# arduino:megaavr@1.8.4 has a dependency on arduino:avrdude@6.3.0-arduino16
213+
assert run_command("core install arduino:megaavr@1.8.4")
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:avr-gcc@7.3.0-atmel3.6.1-arduino5 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:avrdude@6.3.0-arduino17 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)
Please sign in to comment.