Improve test behavior with custom installation directory (#10048)

## Summary

Testing with `UV_PYTHON_INSTALL_DIR` environment variable has some
problems. This PR fix them.

- `UV_PYTHON_INSTALL_DIR` must be an absolute path.
- Cargo tries to find Python executables from each crates in test. If it
is relative path, cargo searches in different directories for each
tests.
- Skip the test asserting help messages.
- Clap shows the current value of the environment variables. If
`UV_PYTHON_INSTALL_DIR` is set, the test fails.

## Test Plan

<!-- How was it tested? -->

All tests pass with
`UV_PYTHON_INSTALL_DIR=/path/to/my/home/uv/target/testpython`.
This commit is contained in:
1hakusai1
2025-03-03 12:58:50 +09:00
committed by GitHub
parent fb6d5d8b4b
commit 6f7d6c420b
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ Testing uv requires multiple specific Python versions; they can be installed wit
cargo run python install
```
The storage directory can be configured with `UV_PYTHON_INSTALL_DIR`.
The storage directory can be configured with `UV_PYTHON_INSTALL_DIR`. (It must be an absolute path.)
### Snapshot testing
+3 -1
View File
@@ -1,3 +1,5 @@
use uv_static::EnvVars;
use crate::common::{uv_snapshot, TestContext};
#[test]
@@ -452,7 +454,7 @@ fn help_subcommand() {
fn help_subsubcommand() {
let context = TestContext::new_with_versions(&[]);
uv_snapshot!(context.filters(), context.help().arg("python").arg("install"), @r###"
uv_snapshot!(context.filters(), context.help().env_remove(EnvVars::UV_PYTHON_INSTALL_DIR).arg("python").arg("install"), @r###"
success: true
exit_code: 0
----- stdout -----