Skip to content

Commit dd14cdc

Browse files
committed
make regexes more robust (hopefully fix Windows?)
1 parent c04856e commit dd14cdc

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

crates/uv/tests/it/common/mod.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use regex::Regex;
2222

2323
use tokio::io::AsyncWriteExt;
2424
use uv_cache::Cache;
25-
use uv_fs::Simplified;
25+
use uv_fs::{PythonExt, Simplified};
2626
use uv_python::managed::ManagedPythonInstallations;
2727
use uv_python::{
2828
EnvironmentPreference, PythonInstallation, PythonPreference, PythonRequest, PythonVersion,
@@ -243,23 +243,27 @@ impl TestContext {
243243
self
244244
}
245245

246-
/// Filtering for the `home = foo/bar/baz/python3.X.X/bin` key in a `pyvenv.cfg` file
246+
/// Filtering for various keys in a `pyvenv.cfg` file that will vary
247+
/// depending on the specific machine used:
248+
/// - `home = foo/bar/baz/python3.X.X/bin`
249+
/// - `uv = X.Y.Z`
250+
/// - `extends-environment = <path/to/parent/venv>`
247251
#[must_use]
248-
pub fn with_filtered_python_home_key(mut self) -> Self {
249-
self.filters.push((
250-
r"\nhome = .+\n".to_string(),
251-
"\nhome = [PYTHON_HOME]\n".to_string(),
252-
));
253-
self
254-
}
255-
256-
/// Filtering for the `uv = X.Y.Z` key in a `pyvenv.cfg` file
257-
#[must_use]
258-
pub fn with_filtered_uv_version(mut self) -> Self {
259-
self.filters.push((
260-
r"\nuv = \d.\d.\d\n".to_string(),
261-
"\nuv = [UV_VERSION]\n".to_string(),
262-
));
252+
pub fn with_pyvenv_cfg_filters(mut self) -> Self {
253+
let added_filters = [
254+
(r"home = .+".to_string(), "home = [PYTHON_HOME]".to_string()),
255+
(
256+
r"uv = \d+\.\d+\.\d+".to_string(),
257+
"uv = [UV_VERSION]".to_string(),
258+
),
259+
(
260+
r"extends-environment = .+".to_string(),
261+
"extends-environment = [PARENT_VENV]".to_string(),
262+
),
263+
];
264+
for filter in added_filters {
265+
self.filters.insert(0, filter);
266+
}
263267
self
264268
}
265269

crates/uv/tests/it/run.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,17 +1269,14 @@ fn run_with() -> Result<()> {
12691269
/// search paths are available in these ephemeral environments.
12701270
#[test]
12711271
fn run_with_pyvenv_cfg_file() -> Result<()> {
1272-
let context = TestContext::new("3.12")
1273-
.with_filtered_python_home_key()
1274-
.with_filtered_uv_version();
1272+
let context = TestContext::new("3.12").with_pyvenv_cfg_filters();
12751273

12761274
let pyproject_toml = context.temp_dir.child("pyproject.toml");
12771275
pyproject_toml.write_str(indoc! { r#"
12781276
[project]
12791277
name = "foo"
12801278
version = "1.0.0"
12811279
requires-python = ">=3.8"
1282-
dependencies = ["sniffio==1.3.0"]
12831280
12841281
[build-system]
12851282
requires = ["setuptools>=42"]
@@ -1306,15 +1303,14 @@ fn run_with_pyvenv_cfg_file() -> Result<()> {
13061303
version_info = 3.12.[X]
13071304
include-system-site-packages = false
13081305
relocatable = true
1309-
extends-environment = [VENV]/
1306+
extends-environment = [PARENT_VENV]
13101307
13111308
13121309
----- stderr -----
1313-
Resolved 2 packages in [TIME]
1314-
Prepared 2 packages in [TIME]
1315-
Installed 2 packages in [TIME]
1310+
Resolved 1 package in [TIME]
1311+
Prepared 1 package in [TIME]
1312+
Installed 1 package in [TIME]
13161313
+ foo==1.0.0 (from file://[TEMP_DIR]/)
1317-
+ sniffio==1.3.0
13181314
Resolved 1 package in [TIME]
13191315
Prepared 1 package in [TIME]
13201316
Installed 1 package in [TIME]

0 commit comments

Comments
 (0)