@@ -320,3 +320,28 @@ func TestCoreUninstall(t *testing.T) {
320320 require .NoError (t , err )
321321 requirejson .Empty (t , stdout )
322322}
323+
324+ func TestCoreUninstallToolDependencyRemoval (t * testing.T ) {
325+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
326+ defer env .CleanUp ()
327+
328+ // These platforms both have a dependency on the arduino:avr-gcc@7.3.0-atmel3.6.1-arduino5 tool
329+ // arduino:avr@1.8.2 has a dependency on arduino:avrdude@6.3.0-arduino17
330+ _ , _ , err := cli .Run ("core" , "install" , "arduino:avr@1.8.2" )
331+ require .NoError (t , err )
332+ // arduino:megaavr@1.8.4 has a dependency on arduino:avrdude@6.3.0-arduino16
333+ _ , _ , err = cli .Run ("core" , "install" , "arduino:megaavr@1.8.4" )
334+ require .NoError (t , err )
335+ _ , _ , err = cli .Run ("core" , "uninstall" , "arduino:avr" )
336+ require .NoError (t , err )
337+
338+ arduinoToolsPath := cli .DataDir ().Join ("packages" , "arduino" , "tools" )
339+
340+ avrGccBinariesPath := arduinoToolsPath .Join ("avr-gcc" , "7.3.0-atmel3.6.1-arduino5" , "bin" )
341+ // The tool arduino:avr-gcc@7.3.0-atmel3.6.1-arduino5 that is a dep of another installed platform should remain
342+ require .True (t , avrGccBinariesPath .Join ("avr-gcc" ).Exist () || avrGccBinariesPath .Join ("avr-gcc.exe" ).Exist ())
343+
344+ avrDudeBinariesPath := arduinoToolsPath .Join ("avrdude" , "6.3.0-arduino17" , "bin" )
345+ // The tool arduino:avrdude@6.3.0-arduino17 that is only a dep of arduino:avr should have been removed
346+ require .False (t , avrDudeBinariesPath .Join ("avrdude" ).Exist () || avrDudeBinariesPath .Join ("avrdude.exe" ).Exist ())
347+ }
0 commit comments