Skip to content

test(test-tool): uninstall all versions and clear cache before installation#6393

Merged
jdx merged 5 commits intomainfrom
feat/test-tool-uninstall-reset
Sep 24, 2025
Merged

test(test-tool): uninstall all versions and clear cache before installation#6393
jdx merged 5 commits intomainfrom
feat/test-tool-uninstall-reset

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Sep 24, 2025

Summary

  • Modified mise test-tool to uninstall all existing versions and clear cache before testing
  • Added e2e test to verify the new behavior

Details

This ensures a clean state when testing tools by:

  • Uninstalling all existing versions of the tool
  • Clearing the backend cache directory
  • Then performing a fresh installation and test

This helps ensure tests are reproducible and not affected by previous installations or cached data.

Test plan

  • Added e2e test test_test_tool_clean to verify the cleanup behavior
  • Verified existing test-tool functionality still works

🤖 Generated with Claude Code

…lation

This ensures a clean state when testing tools by:
- Uninstalling all existing versions of the tool
- Clearing the backend cache directory
- Then performing a fresh installation and test

This helps ensure tests are reproducible and not affected by previous
installations or cached data.
Copilot AI review requested due to automatic review settings September 24, 2025 12:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the mise test-tool command to ensure a clean testing environment by uninstalling all existing versions and clearing cache before testing. This makes tool testing more reproducible by eliminating interference from previous installations or cached data.

  • Adds cleanup logic to uninstall all installed versions and clear cache before running tests
  • Implements proper progress reporting during the cleanup process
  • Adds comprehensive e2e test coverage to verify the new cleanup behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/cli/test_tool.rs Adds cleanup logic to uninstall all versions and clear cache before testing
e2e/cli/test_test_tool_clean Adds comprehensive e2e test to verify cleanup behavior works correctly

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// List and uninstall all installed versions
let installed_versions = backend.list_installed_versions();
debug!("Backend short name: {}", tool.ba.short);
debug!("Tool short name: {}", tool.short);
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These debug statements appear to be leftover from development. Consider removing them as they don't add value in production and the information is already available through other logging.

Suggested change
debug!("Tool short name: {}", tool.short);

Copilot uses AI. Check for mistakes.
Comment on lines +167 to +173
let request = crate::toolset::ToolRequest::Version {
backend: tool.ba.clone(),
version: version.clone(),
options: Default::default(),
source: crate::toolset::ToolSource::Unknown,
};
let tv = crate::toolset::ToolVersion::new(request, version);
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version is cloned twice unnecessarily. Consider using version.clone() only once and reusing it, or restructure to avoid the extra clone in line 173.

Suggested change
let request = crate::toolset::ToolRequest::Version {
backend: tool.ba.clone(),
version: version.clone(),
options: Default::default(),
source: crate::toolset::ToolSource::Unknown,
};
let tv = crate::toolset::ToolVersion::new(request, version);
let version_cloned = version.clone();
let request = crate::toolset::ToolRequest::Version {
backend: tool.ba.clone(),
version: version_cloned.clone(),
options: Default::default(),
source: crate::toolset::ToolSource::Unknown,
};
let tv = crate::toolset::ToolVersion::new(request, version_cloned);

Copilot uses AI. Check for mistakes.
jdx added 2 commits September 24, 2025 07:45
…ling

- Clear downloads directory in addition to cache directory
- Call Config::reset() after uninstalling to clear in-memory backend metadata caches
- Only reset config if we actually uninstalled any versions
Instead of uninstalling each version, directly remove the entire
installs, cache, and downloads directories for the tool. This is
simpler and more thorough.
cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.16 x -- echo 19.5 ± 0.3 18.9 21.8 1.00
mise x -- echo 19.5 ± 0.4 19.1 26.5 1.00 ± 0.03

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.16 env 18.9 ± 0.5 18.3 23.6 1.00
mise env 19.0 ± 0.3 18.4 20.3 1.01 ± 0.03

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.16 hook-env 18.9 ± 0.3 18.2 22.6 1.01 ± 0.03
mise hook-env 18.7 ± 0.3 18.1 20.2 1.00

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.16 ls 16.4 ± 0.2 16.0 17.4 1.00
mise ls 16.5 ± 0.2 16.1 17.6 1.01 ± 0.02

xtasks/test/perf

Command mise-2025.9.16 mise Variance
install (cached) 169ms ✅ 103ms +64%
ls (cached) 63ms 62ms +1%
bin-paths (cached) 70ms 69ms +1%
task-ls (cached) 467ms 476ms -1%

✅ Performance improvement: install cached is 64%

jdx added 2 commits September 24, 2025 08:43
The test now properly validates that test-tool cleans directories
before installation. Updated to use --include-non-defined flag
for tiny since it lacks a test definition, and to handle the
expected test failure gracefully while still validating the
cleaning behavior.
Replaced tiny with shellcheck in the test since shellcheck has a proper
test definition in the registry. This eliminates the need for the
--include-non-defined flag and handling expected failures, making the
test cleaner and more straightforward.
@jdx jdx enabled auto-merge (squash) September 24, 2025 13:47
// Reset the config to clear in-memory backend metadata caches if we cleaned anything
if cleaned_any {
*config = Config::reset().await?;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cleanup Fails, Report Incomplete

The cleanup logic only removes directories for the main tool, not its dependencies, which can lead to inconsistent test states. Also, if any directory removal fails, the progress report's finish() method is skipped, leaving the report unfinished and potentially causing UI issues.

Fix in Cursor Fix in Web

@jdx jdx merged commit 96e008f into main Sep 24, 2025
55 of 58 checks passed
@jdx jdx deleted the feat/test-tool-uninstall-reset branch September 24, 2025 20:14
@jdx jdx mentioned this pull request Sep 24, 2025
jdx added a commit that referenced this pull request Sep 25, 2025
### 📦 Registry

- replace amplify-cli github backend with ubi by @eggplants in
[#6396](#6396)

### 🚀 Features

- **(template)** add read_file() function by @jdx in
[#6400](#6400)

### 🐛 Bug Fixes

- **(aqua)** support github_artifact_attestations.enabled by @risu729 in
[#6372](#6372)
- use /c instead of -c on windows in postinstall hook by @risu729 in
[#6397](#6397)

### 🧪 Testing

- **(test-tool)** uninstall all versions and clear cache before
installation by @jdx in [#6393](#6393)

### New Contributors

- @eggplants made their first contribution in
[#6396](#6396)

Co-authored-by: mise-en-dev <release@mise.jdx.dev>
@jdx jdx mentioned this pull request Sep 25, 2025
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 25, 2025
## [2025.9.18](https://github.com/jdx/mise/compare/v2025.9.17..v2025.9.18) - 2025-09-24

### 📦 Registry

- replace amplify-cli github backend with ubi by @eggplants in [#6396](jdx/mise#6396)

### 🚀 Features

- **(template)** add read_file() function by @jdx in [#6400](jdx/mise#6400)

### 🐛 Bug Fixes

- **(aqua)** support github_artifact_attestations.enabled by @risu729 in [#6372](jdx/mise#6372)
- use /c instead of -c on windows in postinstall hook by @risu729 in [#6397](jdx/mise#6397)

### 🧪 Testing

- **(test-tool)** uninstall all versions and clear cache before installation by @jdx in [#6393](jdx/mise#6393)

### New Contributors

- @eggplants made their first contribution in [#6396](jdx/mise#6396)

## [2025.9.17](https://github.com/jdx/mise/compare/v2025.9.16..v2025.9.17) - 2025-09-24

### 🚀 Features

- **(java)** add support for Liberica NIK releases by @roele in [#6382](jdx/mise#6382)

### 🐛 Bug Fixes

- **(toolset)** handle underflow in version_sub function by @koh-sh in [#6389](jdx/mise#6389)

### 📚 Documentation

- document MISE_ENV behavior for global/system configs by @jdx in [#6385](jdx/mise#6385)

### New Contributors

- @jc00ke made their first contribution in [#6386](jdx/mise#6386)
- @koh-sh made their first contribution in [#6389](jdx/mise#6389)
riastradh pushed a commit to riastradh/pkgsrc-test20250901 that referenced this pull request Feb 8, 2026
## [2025.9.18](https://github.com/jdx/mise/compare/v2025.9.17..v2025.9.18) - 2025-09-24

### 📦 Registry

- replace amplify-cli github backend with ubi by @eggplants in [#6396](jdx/mise#6396)

### 🚀 Features

- **(template)** add read_file() function by @jdx in [#6400](jdx/mise#6400)

### 🐛 Bug Fixes

- **(aqua)** support github_artifact_attestations.enabled by @risu729 in [#6372](jdx/mise#6372)
- use /c instead of -c on windows in postinstall hook by @risu729 in [#6397](jdx/mise#6397)

### 🧪 Testing

- **(test-tool)** uninstall all versions and clear cache before installation by @jdx in [#6393](jdx/mise#6393)

### New Contributors

- @eggplants made their first contribution in [#6396](jdx/mise#6396)

## [2025.9.17](https://github.com/jdx/mise/compare/v2025.9.16..v2025.9.17) - 2025-09-24

### 🚀 Features

- **(java)** add support for Liberica NIK releases by @roele in [#6382](jdx/mise#6382)

### 🐛 Bug Fixes

- **(toolset)** handle underflow in version_sub function by @koh-sh in [#6389](jdx/mise#6389)

### 📚 Documentation

- document MISE_ENV behavior for global/system configs by @jdx in [#6385](jdx/mise#6385)

### New Contributors

- @jc00ke made their first contribution in [#6386](jdx/mise#6386)
- @koh-sh made their first contribution in [#6389](jdx/mise#6389)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants