-
Notifications
You must be signed in to change notification settings - Fork 81
#1659: abort runTool with warning when global tool installer runs in background #2113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ali-Shariati-Najafabadi
wants to merge
5
commits into
devonfw:main
Choose a base branch
from
Ali-Shariati-Najafabadi:feature/1659-global-tool-async-install
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8352997
#1659: abort runTool with warning when global tool installer runs in …
Ali-Shariati-Najafabadi e47d7d4
#1659: Add test for {GlobalToolCommandlet}.
Ali-Shariati-Najafabadi 6f544c4
#1659: Update CHANGELOG for release 2026.07.001
Ali-Shariati-Najafabadi 09792db
Merge branch 'main' into feature/1659-global-tool-async-install
Ali-Shariati-Najafabadi e0ff246
#1659: move async-install warning from runTool to install to cover th…
Ali-Shariati-Najafabadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
cli/src/test/java/com/devonfw/tools/ide/tool/GlobalToolCommandletTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package com.devonfw.tools.ide.tool; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import com.devonfw.tools.ide.common.Tag; | ||
| import com.devonfw.tools.ide.context.AbstractIdeContextTest; | ||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.context.IdeTestContext; | ||
| import com.devonfw.tools.ide.os.SystemInfoMock; | ||
| import com.devonfw.tools.ide.process.ProcessResult; | ||
| import com.devonfw.tools.ide.version.VersionIdentifier; | ||
| import com.devonfw.tools.ide.tool.ToolEdition; | ||
| import com.devonfw.tools.ide.tool.ToolEditionAndVersion; | ||
|
|
||
| /** | ||
| * Test of {@link GlobalToolCommandlet}. | ||
| */ | ||
| class GlobalToolCommandletTest extends AbstractIdeContextTest { | ||
|
|
||
| private static final String TOOL_NAME = "docker"; | ||
|
|
||
| private static final String TOOL_VERSION = "1.21.0"; | ||
|
|
||
| /** | ||
| * Dummy {@link GlobalToolCommandlet} that simulates a background GUI installer (e.g. Rancher Desktop on Windows). | ||
| * Only {@code doInstall} is overridden so the warning-check inside the real {@code install()} is exercised. | ||
| */ | ||
| static class AsyncInstallerToolCommandlet extends GlobalToolCommandlet { | ||
|
|
||
| AsyncInstallerToolCommandlet(IdeContext context) { | ||
|
|
||
| super(context, TOOL_NAME, Set.of(Tag.DOCKER)); | ||
| } | ||
|
|
||
| @Override | ||
| protected void completeRequest(ToolInstallRequest request) { | ||
|
|
||
| VersionIdentifier version = VersionIdentifier.of(TOOL_VERSION); | ||
| ToolEdition edition = new ToolEdition(TOOL_NAME, "rancher"); | ||
| ToolEditionAndVersion requested = new ToolEditionAndVersion(edition, version); | ||
| requested.setResolvedVersion(version); | ||
| request.setRequested(requested); | ||
| } | ||
|
|
||
| @Override | ||
| protected ToolInstallation doInstall(ToolInstallRequest request) { | ||
|
|
||
| VersionIdentifier version = VersionIdentifier.of(TOOL_VERSION); | ||
| return new ToolInstallation(null, null, null, version, true, true); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Verifies that when {@code doInstall} signals an asynchronous background installation, the real {@code install()} logs the warning and {@code runTool} | ||
| * returns exit code 0 without trying to execute the not-yet-available binary. | ||
| */ | ||
| @Test | ||
| void testInstallLogsWarningAndRunToolAbortsWhenInstallationIsAsynchronous() { | ||
|
|
||
| // arrange | ||
| IdeTestContext context = newContext(PROJECT_BASIC); | ||
| context.setSystemInfo(SystemInfoMock.WINDOWS_X64); | ||
| AsyncInstallerToolCommandlet commandlet = new AsyncInstallerToolCommandlet(context); | ||
|
|
||
| // act | ||
| ProcessResult result = commandlet.runTool(List.of("ps")); | ||
|
|
||
| // assert: runTool returns 0 without crashing with "command not found" | ||
| assertThat(result.getExitCode()).isEqualTo(0); | ||
| // assert: warning was emitted by install() covering both "ide install docker" and "ide docker ps" paths | ||
| assertThat(context).logAtWarning().hasMessageContaining("is currently running in the background!"); | ||
| assertThat(context).logAtWarning() | ||
| .hasMessageContaining("rerun your 'ide' command in a new terminal session after the installation has completed."); | ||
| } | ||
|
|
||
| /** | ||
| * Verifies that calling {@code install()} directly (as done by {@code ide install docker}) also logs the background-installation warning. | ||
| */ | ||
| @Test | ||
| void testInstallDirectlyAlsoLogsWarningWhenInstallationIsAsynchronous() { | ||
|
|
||
| // arrange | ||
| IdeTestContext context = newContext(PROJECT_BASIC); | ||
| context.setSystemInfo(SystemInfoMock.WINDOWS_X64); | ||
| AsyncInstallerToolCommandlet commandlet = new AsyncInstallerToolCommandlet(context); | ||
|
|
||
| // act | ||
| ToolInstallation installation = commandlet.install(); | ||
|
|
||
| // assert: the async flag is set | ||
| assertThat(installation.installedAsynchronously()).isTrue(); | ||
| // assert: warning was logged even without runTool being called | ||
| assertThat(context).logAtWarning().hasMessageContaining("is currently running in the background!"); | ||
| assertThat(context).logAtWarning() | ||
| .hasMessageContaining("rerun your 'ide' command in a new terminal session after the installation has completed."); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.