From c16a5fd63040060c7eaa9942500581aed2ef073d Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Wed, 12 Nov 2025 13:55:33 +0000 Subject: [PATCH] Fix shell-specific test snapshots (#16688) ## Summary Two tests were failing when run with `SHELL=fish`: 1. `create_venv_current_working_directory` failed because the "activate" filter didn't apply properly when the venv was in the CWD. This PR fixes the filter. 2. `tool_install_warn_path` failed because the messages are different between fish and bash. This PR hardcodes `SHELL=fish`. ## Test Plan CI --- crates/uv/tests/it/common/mod.rs | 14 ++++++++++++-- crates/uv/tests/it/tool_install.rs | 4 ++-- crates/uv/tests/it/venv.rs | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index d812fab2f..e15e9c782 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -773,8 +773,12 @@ impl TestContext { "Activate with: source $1/[BIN]/activate".to_string(), )); filters.push(( - r"Activate with: source (.*)/bin/activate(?:\.\w+)?".to_string(), - "Activate with: source $1/[BIN]/activate".to_string(), + r"Activate with: Scripts\\activate".to_string(), + "Activate with: source [BIN]/activate".to_string(), + )); + filters.push(( + r"Activate with: source (.*/|)bin/activate(?:\.\w+)?".to_string(), + "Activate with: source $1[BIN]/activate".to_string(), )); // Filter non-deterministic temporary directory names @@ -892,6 +896,12 @@ impl TestContext { )) .unwrap(); + // Ensure the tests aren't sensitive to the running user's shell without forcing + // `bash` on Windows + if cfg!(not(windows)) { + command.env(EnvVars::SHELL, "bash"); + } + command // When running the tests in a venv, ignore that venv, otherwise we'll capture warnings. .env_remove(EnvVars::VIRTUAL_ENV) diff --git a/crates/uv/tests/it/tool_install.rs b/crates/uv/tests/it/tool_install.rs index ced7a7782..2134c28a6 100644 --- a/crates/uv/tests/it/tool_install.rs +++ b/crates/uv/tests/it/tool_install.rs @@ -2848,7 +2848,7 @@ fn tool_install_warn_path() { .arg("black==24.1.1") .env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str()) .env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()) - .env_remove(EnvVars::PATH), @r###" + .env_remove(EnvVars::PATH), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2865,7 +2865,7 @@ fn tool_install_warn_path() { + platformdirs==4.2.0 Installed 2 executables: black, blackd warning: `[TEMP_DIR]/bin` is not on your PATH. To use installed tools, run `export PATH="[TEMP_DIR]/bin:$PATH"` or `uv tool update-shell`. - "###); + "#); } /// Test installing and reinstalling with an invalid receipt. diff --git a/crates/uv/tests/it/venv.rs b/crates/uv/tests/it/venv.rs index 651803aa4..fa5a0161d 100644 --- a/crates/uv/tests/it/venv.rs +++ b/crates/uv/tests/it/venv.rs @@ -1714,7 +1714,7 @@ fn create_venv_current_working_directory() { ----- stderr ----- Using CPython 3.12.[X] interpreter at: [PYTHON-3.12] Creating virtual environment at: . - Activate with: source bin/activate + Activate with: source [BIN]/activate " );