mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Ignore UV_CACHE_DIR
in help
tests (#7895)
This commit is contained in:
parent
ad638d7fa3
commit
ff1a896dd0
5 changed files with 41 additions and 25 deletions
|
@ -16,5 +16,8 @@ indent_size = 4
|
||||||
[*.snap]
|
[*.snap]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[crates/uv/tests/help.rs]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
max_line_length = 100
|
max_line_length = 100
|
||||||
|
|
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -173,11 +173,12 @@ jobs:
|
||||||
- name: "Install Rust toolchain"
|
- name: "Install Rust toolchain"
|
||||||
run: rustup show
|
run: rustup show
|
||||||
|
|
||||||
|
- uses: astral-sh/setup-uv@v3
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: true
|
||||||
- name: "Install required Python versions"
|
- name: "Install required Python versions"
|
||||||
run: |
|
run: uv python install
|
||||||
# astral-sh/setup-uv sets `UV_CACHE_DIR` which disrupts the help message check
|
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
||||||
uv python install
|
|
||||||
|
|
||||||
- name: "Install cargo nextest"
|
- name: "Install cargo nextest"
|
||||||
uses: taiki-e/install-action@v2
|
uses: taiki-e/install-action@v2
|
||||||
|
@ -221,11 +222,12 @@ jobs:
|
||||||
- name: "Install Rust toolchain"
|
- name: "Install Rust toolchain"
|
||||||
run: rustup show
|
run: rustup show
|
||||||
|
|
||||||
|
- uses: astral-sh/setup-uv@v3
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: true
|
||||||
- name: "Install required Python versions"
|
- name: "Install required Python versions"
|
||||||
run: |
|
run: uv python install
|
||||||
# astral-sh/setup-uv sets `UV_CACHE_DIR` which disrupts the help message check
|
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
||||||
uv python install
|
|
||||||
|
|
||||||
- name: "Install cargo nextest"
|
- name: "Install cargo nextest"
|
||||||
uses: taiki-e/install-action@v2
|
uses: taiki-e/install-action@v2
|
||||||
|
|
|
@ -194,6 +194,20 @@ impl TestContext {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ignore `UV_CACHE_DIR` env variable in tests.
|
||||||
|
#[must_use]
|
||||||
|
pub fn with_ignore_cache_dir(mut self) -> Self {
|
||||||
|
self.filters.push((
|
||||||
|
r"\[env:[\n\s]* UV_CACHE_DIR=.+\]".to_string(),
|
||||||
|
"[env: UV_CACHE_DIR=]".to_string(),
|
||||||
|
));
|
||||||
|
// When `--cache-dir` is followed with other options,
|
||||||
|
// remove it from the text. Since its presence is inconsistent.
|
||||||
|
self.filters
|
||||||
|
.push((r"--cache-dir <CACHE_DIR> <".to_string(), "<".to_string()));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Discover the path to the XDG state directory. We use this, rather than the OS-specific
|
/// Discover the path to the XDG state directory. We use this, rather than the OS-specific
|
||||||
/// temporary directory, because on macOS (and Windows on GitHub Actions), they involve
|
/// temporary directory, because on macOS (and Windows on GitHub Actions), they involve
|
||||||
/// symlinks. (On macOS, the temporary directory is, like `/var/...`, which resolves to
|
/// symlinks. (On macOS, the temporary directory is, like `/var/...`, which resolves to
|
||||||
|
|
|
@ -4,7 +4,7 @@ mod common;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help() {
|
fn help() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
// The `uv help` command should show the long help message
|
// The `uv help` command should show the long help message
|
||||||
uv_snapshot!(context.filters(), context.help(), @r###"
|
uv_snapshot!(context.filters(), context.help(), @r###"
|
||||||
|
@ -74,7 +74,8 @@ fn help() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_flag() {
|
fn help_flag() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.command().arg("--help"), @r###"
|
uv_snapshot!(context.filters(), context.command().arg("--help"), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
|
@ -140,7 +141,8 @@ fn help_flag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_short_flag() {
|
fn help_short_flag() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.command().arg("-h"), @r###"
|
uv_snapshot!(context.filters(), context.command().arg("-h"), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
|
@ -206,7 +208,7 @@ fn help_short_flag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_subcommand() {
|
fn help_subcommand() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.help().arg("python"), @r###"
|
uv_snapshot!(context.filters(), context.help().arg("python"), @r###"
|
||||||
success: true
|
success: true
|
||||||
|
@ -394,7 +396,7 @@ fn help_subcommand() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_subsubcommand() {
|
fn help_subsubcommand() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.help().arg("python").arg("install"), @r###"
|
uv_snapshot!(context.filters(), context.help().arg("python").arg("install"), @r###"
|
||||||
success: true
|
success: true
|
||||||
|
@ -562,7 +564,7 @@ fn help_subsubcommand() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_flag_subcommand() {
|
fn help_flag_subcommand() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.command().arg("python").arg("--help"), @r###"
|
uv_snapshot!(context.filters(), context.command().arg("python").arg("--help"), @r###"
|
||||||
success: true
|
success: true
|
||||||
|
@ -618,7 +620,7 @@ fn help_flag_subcommand() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_flag_subsubcommand() {
|
fn help_flag_subsubcommand() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.command().arg("python").arg("install").arg("--help"), @r###"
|
uv_snapshot!(context.filters(), context.command().arg("python").arg("install").arg("--help"), @r###"
|
||||||
success: true
|
success: true
|
||||||
|
@ -747,7 +749,7 @@ fn help_unknown_subsubcommand() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_with_global_option() {
|
fn help_with_global_option() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(context.filters(), context.help().arg("--no-cache"), @r###"
|
uv_snapshot!(context.filters(), context.help().arg("--no-cache"), @r###"
|
||||||
success: true
|
success: true
|
||||||
|
@ -849,7 +851,7 @@ fn help_with_version() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_with_no_pager() {
|
fn help_with_no_pager() {
|
||||||
let context = TestContext::new_with_versions(&[]);
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
// We can't really test whether the --no-pager option works with a snapshot test.
|
// We can't really test whether the --no-pager option works with a snapshot test.
|
||||||
// It's still nice to have a test for the option to confirm the option exists.
|
// It's still nice to have a test for the option to confirm the option exists.
|
||||||
|
|
|
@ -12,13 +12,10 @@ use crate::common::{get_bin, venv_to_interpreter, TestContext};
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_arguments() -> Result<()> {
|
fn no_arguments() {
|
||||||
let temp_dir = assert_fs::TempDir::new()?;
|
let context = TestContext::new_with_versions(&[]).with_ignore_cache_dir();
|
||||||
|
|
||||||
uv_snapshot!(Command::new(get_bin())
|
uv_snapshot!(context.filters(), context.pip_uninstall(), @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("uninstall")
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 2
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -32,8 +29,6 @@ fn no_arguments() -> Result<()> {
|
||||||
For more information, try '--help'.
|
For more information, try '--help'.
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue