test(vfox): replace flaky external HTTP tests with local mock server#6354
test(vfox): replace flaky external HTTP tests with local mock server#6354
Conversation
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR replaces flaky external HTTP tests with a local mock server to improve test reliability and speed. The tests were previously dependent on external services like httpbin.org which could cause intermittent failures in CI environments.
- Replaced external HTTP calls with httpmock library for controlled testing
- Removed
#[ignore]annotation from previously flaky download test - Added necessary build dependencies for cross-compilation support
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/vfox/Cargo.toml | Added httpmock dev dependency for test mocking |
| crates/vfox/src/lua_mod/http.rs | Replaced external HTTP calls with local mock server endpoints |
| src/backend/aqua.rs | Simplified GitHub token retrieval using env module |
| packaging/dev/Dockerfile | Added clang and libclang-dev for build requirements |
| .github/workflows/test-plugins.yml | Added cross tool installation for CI |
| .devcontainer/devcontainer.json | Added MISE_TRUSTED_CONFIG_PATHS environment variable |
| .devcontainer/post-create.sh | Added mise install command to post-create script |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
crates/vfox/src/lua_mod/http.rs
Outdated
| let path = "test/data/test_download_file.txt"; | ||
| lua.load(mlua::chunk! { | ||
|
|
||
| let path = "/tmp/vfox_test_download_file.txt"; |
There was a problem hiding this comment.
Using hardcoded /tmp/ path may fail on Windows systems. Consider using std::env::temp_dir() or tempfile::tempdir() for cross-platform compatibility.
crates/vfox/src/lua_mod/http.rs
Outdated
| lua.load(format!( | ||
| r#" | ||
| local http = require("http") | ||
| local resp = http.get({ url = "https://httpbin.org/get" }) | ||
| local resp = http.get({{ url = "{}" }}) | ||
| assert(resp.status_code == 200) | ||
| assert(type(resp.body) == "string") | ||
| }) | ||
| "#, | ||
| url | ||
| )) |
There was a problem hiding this comment.
[nitpick] Using string formatting for Lua code makes it harder to read and maintain. Consider using mlua::chunk! macro with variable injection for better readability and IDE support.
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
crates/vfox/src/lua_mod/file.rs
Outdated
| let temp_dir = std::env::temp_dir(); | ||
| let filepath = temp_dir.join("vfox-lua-file-read"); | ||
| let filepath_str = filepath.to_string_lossy().to_string(); | ||
| fs::write(&filepath, "hello world").unwrap(); |
There was a problem hiding this comment.
Using a fixed filename in the shared system temp directory can cause race conditions or flaky failures if tests run concurrently (e.g. parallel cargo test or multiple processes). Prefer generating a unique temp file (e.g. with tempfile::NamedTempFile) to isolate the test. Example: let file = tempfile::NamedTempFile::new().unwrap(); let filepath_str = file.path().to_string_lossy().to_string(); then write via std::fs::write(file.path(), "hello world") and use filepath_str in the Lua chunk.
crates/vfox/src/lua_mod/file.rs
Outdated
| let temp_dir = std::env::temp_dir(); | ||
| let src_path = temp_dir.join("test_symlink_src"); | ||
| let dst_path = temp_dir.join("test_symlink_dst"); | ||
| let src_path_str = src_path.to_string_lossy().to_string(); | ||
| let dst_path_str = dst_path.to_string_lossy().to_string(); | ||
| let _ = fs::remove_file(&dst_path); |
There was a problem hiding this comment.
Reusing deterministic names in the global temp directory risks collisions between concurrent test runs (dst_path could be removed or overwritten by another run). Use a per-test TempDir (tempfile::TempDir) and derive src/dst paths from it to ensure isolation: let temp = tempfile::TempDir::new().unwrap(); let src_path = temp.path().join("src"); let dst_path = temp.path().join("dst");
crates/vfox/src/lua_mod/http.rs
Outdated
| let temp_dir = std::env::temp_dir(); | ||
| let path = temp_dir.join("vfox_test_download_file.txt"); | ||
| let path_str = path.to_string_lossy().to_string(); | ||
| let url = server.url("/index.json"); |
There was a problem hiding this comment.
Static filename in a shared temp directory can lead to interference if tests run in parallel (file removed or contents overwritten). Use a unique path via tempfile::NamedTempFile (and pass its path to Lua) or tempfile::Builder::new().prefix("vfox_download_").tempfile() to avoid collisions.
crates/vfox/src/lua_mod/archiver.rs
Outdated
| let temp_dir = std::env::temp_dir(); | ||
| let dst_path = temp_dir.join("test_zip_dst"); | ||
| let dst_path_str = dst_path.to_string_lossy().to_string(); | ||
| let _ = std::fs::remove_dir_all(&dst_path); |
There was a problem hiding this comment.
Using a fixed directory name under the shared temp directory may cause flaky tests when run concurrently (one test cleaning up while another is using it). Switch to a unique TempDir (let temp = tempfile::TempDir::new().unwrap(); let dst_path = temp.path().join("unzip");) to ensure isolation and automatic cleanup.
75a5704 to
d1309ab
Compare
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
d1309ab to
4d65bf2
Compare
Replace httpmock dependency with wiremock to resolve the async-std discontinuation advisory (RUSTSEC-2025-0052). The httpmock crate has transitive dependencies on async-std which is no longer maintained and has known security vulnerabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
crates/vfox/src/lua_mod/cmd.rs
Outdated
| -- Test with working directory | ||
| local result = cmd.exec("pwd", {cwd = "/tmp"}) | ||
| assert(result:find("/tmp") ~= nil) | ||
| // Test with working directory |
There was a problem hiding this comment.
This should be a Lua comment using '--' instead of '//' which is a Rust comment syntax.
| // Test with working directory | |
| -- Test with working directory |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| let lua = Lua::new(); | ||
| mod_http(&lua).unwrap(); | ||
|
|
||
| let url = server.uri() + "/get"; |
There was a problem hiding this comment.
String concatenation using + creates temporary String allocations. Consider using format! macro for better performance: format!(\"{}/get\", server.uri())
| let url = server.uri() + "/get"; | |
| let url = format!("{}/get", server.uri()); |
| let lua = Lua::new(); | ||
| mod_http(&lua).unwrap(); | ||
|
|
||
| let url = server.uri() + "/get"; |
There was a problem hiding this comment.
String concatenation using + creates temporary String allocations. Consider using format! macro for better performance: format!(\"{}/get\", server.uri())
| let url = server.uri() + "/get"; | |
| let url = format!("{}/get", server.uri()); |
| let temp_dir = tempfile::TempDir::new().unwrap(); | ||
| let path = temp_dir.path().join("download_file.txt"); | ||
| let path_str = path.to_string_lossy().to_string(); | ||
| let url = server.uri() + "/index.json"; |
There was a problem hiding this comment.
String concatenation using + creates temporary String allocations. Consider using format! macro for better performance: format!(\"{}/index.json\", server.uri())
| let url = server.uri() + "/index.json"; | |
| let url = format!("{}/index.json", server.uri()); |
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 x -- echo |
20.8 ± 0.3 | 20.0 | 21.9 | 1.00 |
mise x -- echo |
20.9 ± 0.9 | 19.9 | 38.2 | 1.00 ± 0.05 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 env |
20.0 ± 0.6 | 19.2 | 26.0 | 1.00 |
mise env |
20.3 ± 0.8 | 19.4 | 31.6 | 1.01 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 hook-env |
19.8 ± 0.4 | 18.8 | 20.8 | 1.00 |
mise hook-env |
20.0 ± 0.5 | 19.0 | 23.3 | 1.01 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 ls |
17.4 ± 0.3 | 16.5 | 19.0 | 1.00 |
mise ls |
17.5 ± 0.4 | 16.7 | 20.7 | 1.01 ± 0.03 |
xtasks/test/perf
| Command | mise-2025.9.14 | mise | Variance |
|---|---|---|---|
| install (cached) | 174ms | ✅ 105ms | +65% |
| ls (cached) | 65ms | 64ms | +1% |
| bin-paths (cached) | 71ms | 70ms | +1% |
| task-ls (cached) | 499ms | 484ms | +3% |
✅ Performance improvement: install cached is 65%
## Summary
Fixes CI test failures in the vfox crate by properly configuring TLS
support for reqwest.
## Problem
The vfox tests were failing in CI because reqwest was configured without
TLS support, causing HTTPS requests to nodejs.org to fail with:
```
ConnectError("invalid URL, scheme is not http")
```
## Solution
Added `native-tls` to vfox's default features, matching mise's default
TLS configuration approach. This ensures:
- vfox tests work out of the box with TLS support
- Consistency with mise's TLS strategy
- mise continues to use `default-features = false` and explicitly
controls which TLS implementation to use
## Changes
- Added `native-tls` to vfox's default features
- vfox now defaults to the same TLS implementation as mise
## Testing
- All vfox tests pass locally
- CI should pass with this change
Follow-up to #6354
---------
Co-authored-by: Claude <noreply@anthropic.com>
### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](#6355) Co-authored-by: mise-en-dev <release@mise.jdx.dev>
## [2025.9.16](https://github.com/jdx/mise/compare/v2025.9.15..v2025.9.16) - 2025-09-22 ### 📦 Registry - use npm backend for zbctl by @risu729 in [#6379](jdx/mise#6379) ### 🐛 Bug Fixes - **(aqua)** remove blake3 support from aqua checksum algorithms by @risu729 in [#6370](jdx/mise#6370) - **(aqua)** remove cosign and slsa-verifier dependencies by @risu729 in [#6371](jdx/mise#6371) - **(aqua)** remove cosign.experimental by @risu729 in [#6376](jdx/mise#6376) ### 📚 Documentation - minisign doesn't require cli by @risu729 in [#6369](jdx/mise#6369) ### Chore - ignore renovate new bot name by @risu729 in [#6364](jdx/mise#6364) ## [2025.9.15](https://github.com/jdx/mise/compare/v2025.9.14..v2025.9.15) - 2025-09-21 ### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](jdx/mise#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](jdx/mise#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](jdx/mise#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](jdx/mise#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](jdx/mise#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](jdx/mise#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](jdx/mise#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](jdx/mise#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](jdx/mise#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](jdx/mise#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](jdx/mise#6355) ## [2025.9.14](https://github.com/jdx/mise/compare/v2025.9.13..v2025.9.14) - 2025-09-20 ### 🐛 Bug Fixes - fix an issue where Swift could not be installed on arm64 Ubuntu by @lish82 in [#6348](jdx/mise#6348) ### Chore - use cross to build on linux by @jdx in [#6346](jdx/mise#6346) ### New Contributors - @lish82 made their first contribution in [#6348](jdx/mise#6348) ## [2025.9.13](https://github.com/jdx/mise/compare/v2025.9.12..v2025.9.13) - 2025-09-19 ### 📦 Registry - remove deprecated virtualos by @jdx in [166379f](jdx/mise@166379f) - add trufflehog ([aqua:trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog)) by @risu729 in [#6316](jdx/mise#6316) ### 🚀 Features - **(aqua)** integrate native sigstore-verification for security verification by @jdx in [#6332](jdx/mise#6332) - **(docs)** improve search result readability with lighter teal background by @jdx in [#6328](jdx/mise#6328) - **(ui)** update logo as favicon and fix hover transitions by @jdx in [#6325](jdx/mise#6325) - **(vfox)** add file.read lua function by @malept in [#6333](jdx/mise#6333) - add documentation for "Environment in tasks" #5134 #5638 by @Its-Just-Nans in [#6329](jdx/mise#6329) ### 🐛 Bug Fixes - **(github)** correctly paginate releases/tags for private repos by @malept in [#6318](jdx/mise#6318) - **(hk)** exclude aqua-registry from prettier linting by @jdx in [#6327](jdx/mise#6327) - **(ui)** improve GitHub star badge layout and alignment by @jdx in [#6326](jdx/mise#6326) ### 📚 Documentation - change 'hello.py' to 'main.py' in python.md by @my1e5 in [#6319](jdx/mise#6319) - customize VitePress theme with unique branding by @jdx in [#6324](jdx/mise#6324) ### 📦️ Dependency Updates - update taiki-e/install-action digest to 0aa4f22 by @renovate[bot] in [#6334](jdx/mise#6334) - update rust crate comfy-table to v7.2.1 by @renovate[bot] in [#6335](jdx/mise#6335) - update rust crate console to v0.16.1 by @renovate[bot] in [#6336](jdx/mise#6336) - update rust crate indexmap to v2.11.4 by @renovate[bot] in [#6337](jdx/mise#6337) ### Chore - fixing typos by @Its-Just-Nans in [#6331](jdx/mise#6331) ### New Contributors - @Its-Just-Nans made their first contribution in [#6331](jdx/mise#6331) - @my1e5 made their first contribution in [#6319](jdx/mise#6319)
## [2025.9.16](https://github.com/jdx/mise/compare/v2025.9.15..v2025.9.16) - 2025-09-22 ### 📦 Registry - use npm backend for zbctl by @risu729 in [#6379](jdx/mise#6379) ### 🐛 Bug Fixes - **(aqua)** remove blake3 support from aqua checksum algorithms by @risu729 in [#6370](jdx/mise#6370) - **(aqua)** remove cosign and slsa-verifier dependencies by @risu729 in [#6371](jdx/mise#6371) - **(aqua)** remove cosign.experimental by @risu729 in [#6376](jdx/mise#6376) ### 📚 Documentation - minisign doesn't require cli by @risu729 in [#6369](jdx/mise#6369) ### Chore - ignore renovate new bot name by @risu729 in [#6364](jdx/mise#6364) ## [2025.9.15](https://github.com/jdx/mise/compare/v2025.9.14..v2025.9.15) - 2025-09-21 ### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](jdx/mise#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](jdx/mise#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](jdx/mise#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](jdx/mise#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](jdx/mise#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](jdx/mise#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](jdx/mise#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](jdx/mise#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](jdx/mise#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](jdx/mise#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](jdx/mise#6355) ## [2025.9.14](https://github.com/jdx/mise/compare/v2025.9.13..v2025.9.14) - 2025-09-20 ### 🐛 Bug Fixes - fix an issue where Swift could not be installed on arm64 Ubuntu by @lish82 in [#6348](jdx/mise#6348) ### Chore - use cross to build on linux by @jdx in [#6346](jdx/mise#6346) ### New Contributors - @lish82 made their first contribution in [#6348](jdx/mise#6348) ## [2025.9.13](https://github.com/jdx/mise/compare/v2025.9.12..v2025.9.13) - 2025-09-19 ### 📦 Registry - remove deprecated virtualos by @jdx in [166379f](jdx/mise@166379f) - add trufflehog ([aqua:trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog)) by @risu729 in [#6316](jdx/mise#6316) ### 🚀 Features - **(aqua)** integrate native sigstore-verification for security verification by @jdx in [#6332](jdx/mise#6332) - **(docs)** improve search result readability with lighter teal background by @jdx in [#6328](jdx/mise#6328) - **(ui)** update logo as favicon and fix hover transitions by @jdx in [#6325](jdx/mise#6325) - **(vfox)** add file.read lua function by @malept in [#6333](jdx/mise#6333) - add documentation for "Environment in tasks" #5134 #5638 by @Its-Just-Nans in [#6329](jdx/mise#6329) ### 🐛 Bug Fixes - **(github)** correctly paginate releases/tags for private repos by @malept in [#6318](jdx/mise#6318) - **(hk)** exclude aqua-registry from prettier linting by @jdx in [#6327](jdx/mise#6327) - **(ui)** improve GitHub star badge layout and alignment by @jdx in [#6326](jdx/mise#6326) ### 📚 Documentation - change 'hello.py' to 'main.py' in python.md by @my1e5 in [#6319](jdx/mise#6319) - customize VitePress theme with unique branding by @jdx in [#6324](jdx/mise#6324) ### 📦️ Dependency Updates - update taiki-e/install-action digest to 0aa4f22 by @renovate[bot] in [#6334](jdx/mise#6334) - update rust crate comfy-table to v7.2.1 by @renovate[bot] in [#6335](jdx/mise#6335) - update rust crate console to v0.16.1 by @renovate[bot] in [#6336](jdx/mise#6336) - update rust crate indexmap to v2.11.4 by @renovate[bot] in [#6337](jdx/mise#6337) ### Chore - fixing typos by @Its-Just-Nans in [#6331](jdx/mise#6331) ### New Contributors - @Its-Just-Nans made their first contribution in [#6331](jdx/mise#6331) - @my1e5 made their first contribution in [#6319](jdx/mise#6319)
Summary
Fixes flaky vfox HTTP tests by replacing external service dependencies with a local mock server and improving test isolation.
Changes
1. Replaced external HTTP tests with local mock server
2. Fixed cross-platform compatibility
/tmppaths withstd::env::temp_dir()3. Improved test isolation
tempfile::TempDirinstances4. Enhanced code readability
mlua::chunk!macro with variable injection5. Resolved security advisory
httpmockwithwiremockto fix RUSTSEC-2025-0052async-stdcrateTesting
Fixes flaky test issue seen in: https://github.com/jdx/mise/actions/runs/17885055691/job/50857630121?pr=6352