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
This commit is contained in:
Zsolt Dollenstein 2025-11-12 13:55:33 +00:00 committed by GitHub
parent d32cc638d1
commit c16a5fd630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View file

@ -773,8 +773,12 @@ impl TestContext {
"Activate with: source $1/[BIN]/activate".to_string(), "Activate with: source $1/[BIN]/activate".to_string(),
)); ));
filters.push(( filters.push((
r"Activate with: source (.*)/bin/activate(?:\.\w+)?".to_string(), r"Activate with: Scripts\\activate".to_string(),
"Activate with: source $1/[BIN]/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 // Filter non-deterministic temporary directory names
@ -892,6 +896,12 @@ impl TestContext {
)) ))
.unwrap(); .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 command
// When running the tests in a venv, ignore that venv, otherwise we'll capture warnings. // When running the tests in a venv, ignore that venv, otherwise we'll capture warnings.
.env_remove(EnvVars::VIRTUAL_ENV) .env_remove(EnvVars::VIRTUAL_ENV)

View file

@ -2848,7 +2848,7 @@ fn tool_install_warn_path() {
.arg("black==24.1.1") .arg("black==24.1.1")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str()) .env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_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 success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
@ -2865,7 +2865,7 @@ fn tool_install_warn_path() {
+ platformdirs==4.2.0 + platformdirs==4.2.0
Installed 2 executables: black, blackd 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`. 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. /// Test installing and reinstalling with an invalid receipt.

View file

@ -1714,7 +1714,7 @@ fn create_venv_current_working_directory() {
----- stderr ----- ----- stderr -----
Using CPython 3.12.[X] interpreter at: [PYTHON-3.12] Using CPython 3.12.[X] interpreter at: [PYTHON-3.12]
Creating virtual environment at: . Creating virtual environment at: .
Activate with: source bin/activate Activate with: source [BIN]/activate
" "
); );