diff --git a/commands/commands_test.go b/commands/commands_test.go index b518bb15ee4..3ef472f5792 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -355,15 +355,20 @@ func TestCoreCommands(t *testing.T) { require.Zero(t, exitCode, "exit code") require.Empty(t, strings.TrimSpace(string(d))) - // Install avr - exitCode, d = executeWithArgs(t, "core", "install", "arduino:avr") + // Install avr 1.6.16 + exitCode, d = executeWithArgs(t, "core", "install", "arduino:avr@1.6.16") require.Zero(t, exitCode, "exit code") - require.Contains(t, string(d), AVR+" installed") + require.Contains(t, string(d), "arduino:avr@1.6.16 installed") exitCode, d = executeWithArgs(t, "core", "list") require.Zero(t, exitCode, "exit code") require.Contains(t, string(d), "arduino:avr") + // List updatable cores + exitCode, d = executeWithArgs(t, "core", "list", "--updatable") + require.Zero(t, exitCode, "exit code") + require.Contains(t, string(d), "arduino:avr") + // Build sketch for arduino:avr:uno exitCode, d = executeWithArgs(t, "sketch", "new", "Test1") require.Zero(t, exitCode, "exit code") @@ -376,7 +381,7 @@ func TestCoreCommands(t *testing.T) { // Uninstall arduino:avr exitCode, d = executeWithArgs(t, "core", "uninstall", "arduino:avr") require.Zero(t, exitCode, "exit code") - require.Contains(t, string(d), AVR+" uninstalled") + require.Contains(t, string(d), "arduino:avr@1.6.16 uninstalled") // Empty cores list exitCode, d = executeWithArgs(t, "core", "list") diff --git a/commands/core/uninstall.go b/commands/core/uninstall.go index f531f20a3ad..45b63a4c925 100644 --- a/commands/core/uninstall.go +++ b/commands/core/uninstall.go @@ -52,6 +52,21 @@ func runUninstallCommand(cmd *cobra.Command, args []string) { } func uninstallPlatformByRef(pm *packagemanager.PackageManager, platformRef *packagemanager.PlatformReference) { + // If no version is specified consider the installed + if platformRef.PlatformVersion == nil { + platform := pm.FindPlatform(platformRef) + if platform == nil { + formatter.PrintErrorMessage("Platform not found " + platformRef.String()) + os.Exit(commands.ErrBadCall) + } + platformRelease := platform.GetInstalled() + if platformRelease == nil { + formatter.PrintErrorMessage("Platform not installed " + platformRef.String()) + os.Exit(commands.ErrBadCall) + } + platformRef.PlatformVersion = platformRelease.Version + } + platform, tools, err := pm.FindPlatformReleaseDependencies(platformRef) if err != nil { formatter.PrintError(err, "Could not determine platform dependencies")