Skip to content

test(vfox): replace flaky external tests with local dummy plugin#6403

Merged
jdx merged 1 commit intomainfrom
fix/vfox-flaky-tests
Sep 25, 2025
Merged

test(vfox): replace flaky external tests with local dummy plugin#6403
jdx merged 1 commit intomainfrom
fix/vfox-flaky-tests

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Sep 24, 2025

Summary

  • Replaced nodejs plugin with local dummy plugin in vfox tests to eliminate network dependencies
  • Tests no longer make external HTTP calls to GitHub or nodejs.org
  • Similar approach to commit b74b778 which fixed flaky HTTP tests with mock servers

Changes Made

  • Modified existing dummy plugin to be completely self-contained (no external calls)
  • Updated test_env_keys, test_install, test_install_plugin, and test_metadata to use dummy plugin instead of nodejs
  • Updated snapshot tests to reflect dummy plugin output
  • Added post_install hook to create dummy installation directories

Testing

  • All vfox tests pass without network access
  • Tests are now deterministic and won't fail due to network issues or rate limits
  • Ran cargo test --package vfox successfully

Related

🤖 Generated with Claude Code

## Summary

- Replaced nodejs plugin with local dummy plugin in vfox tests to eliminate network dependencies
- Tests no longer make external HTTP calls to GitHub or nodejs.org
- Similar approach to commit b74b778 which fixed flaky HTTP tests with mock servers

## Changes Made

- Modified dummy plugin to be completely self-contained (no external calls)
- Updated test_env_keys, test_install, test_install_plugin, and test_metadata to use dummy plugin
- Updated snapshot tests to reflect dummy plugin output
- Added post_install hook to create dummy installation directories

## Testing

- All vfox tests pass without network access
- Tests are now deterministic and won't fail due to network issues or rate limits

## Related

- Fixes flaky test failures seen in CI: https://github.com/jdx/mise/actions/runs/17991508443/job/51182302883

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 24, 2025 23:47
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 replaces flaky external network calls in vfox tests with a local dummy plugin to eliminate dependencies on external services like GitHub and nodejs.org. This makes the tests deterministic and prevents CI failures due to network issues or rate limits.

  • Replaced nodejs plugin tests with dummy plugin tests to eliminate external HTTP calls
  • Updated snapshot tests to reflect dummy plugin output instead of nodejs plugin
  • Enhanced dummy plugin with post_install hook to create installation directories

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/vfox/src/vfox.rs Updated test methods to use dummy plugin instead of nodejs, removed network-dependent operations
crates/vfox/src/snapshots/vfox__vfox__tests__metadata.snap Updated snapshot to reflect dummy plugin metadata instead of nodejs
crates/vfox/src/snapshots/vfox__vfox__tests__env_keys.snap Updated snapshot to show dummy/1.0.0 path instead of nodejs/20.0.0
crates/vfox/plugins/dummy/metadata.lua Fixed trailing comma in legacyFilenames array
crates/vfox/plugins/dummy/hooks/post_install.lua Added logic to create dummy installation directories and executable
crates/vfox/plugins/dummy/hooks/parse_legacy_file.lua Simplified legacy file parsing logic
crates/vfox/plugins/dummy/hooks/available.lua Removed trailing commas from version objects

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

end

-- Create the installation directory structure for dummy plugin
os.execute("mkdir -p " .. rootPath .. "/bin")
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.

Using os.execute with user-controlled input can lead to command injection vulnerabilities. Consider using Lua's built-in file system functions or properly sanitizing the rootPath variable before concatenating it into shell commands.

Copilot uses AI. Check for mistakes.
if dummy_file then
dummy_file:write("#!/bin/sh\necho 'dummy version 1.0.0'\n")
dummy_file:close()
os.execute("chmod +x " .. rootPath .. "/bin/dummy")
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.

Similar to the mkdir command, this os.execute call with concatenated user input poses a command injection risk. Consider using Lua's file system APIs or ensure proper input sanitization.

Copilot uses AI. Check for mistakes.
version = version
}
end
local file = io.open(filepath, "r")
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.

If io.open fails and returns nil, calling file:read() and file:close() on nil will cause a runtime error. Add a nil check after io.open before proceeding with file operations.

Suggested change
local file = io.open(filepath, "r")
local file = io.open(filepath, "r")
if not file then
return {}
end

Copilot uses AI. Check for mistakes.
end
local file = io.open(filepath, "r")
local content = file:read("*a")
file:close()
Copy link

Choose a reason for hiding this comment

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

Bug: File Handling Error: Unchecked io.open Call

The io.open call isn't checked for failure. If the file is missing or unreadable, io.open returns nil, causing a runtime error when file:read or file:close are subsequently called. The previous implementation safely handled this case.

Fix in Cursor Fix in Web

dummy_file:write("#!/bin/sh\necho 'dummy version 1.0.0'\n")
dummy_file:close()
os.execute("chmod +x " .. rootPath .. "/bin/dummy")
end
Copy link

Choose a reason for hiding this comment

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

Bug: Cross-Platform Shell Command Issues

The post_install hook uses non-portable Unix-specific shell commands (mkdir -p, chmod +x) and path separators (/) via os.execute, and writes a sh script. This fails on Windows, preventing directory and binary creation. Unquoted paths also break when rootPath contains spaces, causing installations and tests to fail.

Fix in Cursor Fix in Web

@github-actions
Copy link

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.17 x -- echo 19.7 ± 0.7 18.8 26.0 1.01 ± 0.04
mise x -- echo 19.5 ± 0.4 18.8 23.4 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.17 env 18.8 ± 0.7 18.3 25.2 1.00 ± 0.04
mise env 18.8 ± 0.3 18.2 20.2 1.00

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.17 hook-env 18.4 ± 0.2 18.0 19.2 1.00
mise hook-env 18.6 ± 0.3 18.1 20.3 1.01 ± 0.02

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.17 ls 16.5 ± 0.5 15.9 21.2 1.00
mise ls 16.5 ± 0.4 15.9 19.2 1.00 ± 0.04

xtasks/test/perf

Command mise-2025.9.17 mise Variance
install (cached) 168ms ✅ 102ms +64%
ls (cached) 63ms 62ms +1%
bin-paths (cached) 70ms 69ms +1%
task-ls (cached) 465ms 463ms +0%

✅ Performance improvement: install cached is 64%

@jdx jdx enabled auto-merge (squash) September 25, 2025 00:04
@jdx jdx merged commit b75c871 into main Sep 25, 2025
20 checks passed
@jdx jdx deleted the fix/vfox-flaky-tests branch September 25, 2025 00:21
@jdx jdx mentioned this pull request Sep 25, 2025
jdx added a commit that referenced this pull request Sep 25, 2025
### 📦 Registry

- fix mise-ghcup plugin managed tools descriptions by @risu729 in
[#6411](#6411)
- add Tinymist by @3w36zj6 in
[#6412](#6412)
- revert djinni backend to ubi by @risu729 in
[#6410](#6410)

### 🚀 Features

- **(github)** filter remote versions by version_prefix by @risu729 in
[#6408](#6408)
- Remove experimental labels for GitHub and HTTP backends by @Copilot in
[#6415](#6415)

### 🧪 Testing

- **(vfox)** replace flaky external tests with local dummy plugin by
@jdx in [#6403](#6403)

### New Contributors

- @Copilot made their first contribution in
[#6415](#6415)

Co-authored-by: mise-en-dev <release@mise.jdx.dev>
@jdx jdx mentioned this pull request Sep 25, 2025
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