From 15bf83ced885eb29d4b9307d3d0aec8de3f63672 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sat, 22 Mar 2025 21:57:15 -0500 Subject: [PATCH] Add comments to the `with_filtered_python_keys` regex (#12379) I need to edit this thing and it's a nightmare as written. See https://github.com/astral-sh/uv/pull/12380 --- crates/uv/tests/it/common/mod.rs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index d57918bf9..de23469b6 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -277,11 +277,33 @@ impl TestContext { /// Adds a filter that ignores platform information in a Python installation key. pub fn with_filtered_python_keys(mut self) -> Self { // Filter platform keys - self.filters.push(( - r"((?:cpython|pypy)-\d+\.\d+(?:\.(?:\[X\]|\d+))?[a-z]?(?:\+[a-z]+)?)-[a-z0-9]+-[a-z0-9_]+-[a-z]+" - .to_string(), - "$1-[PLATFORM]".to_string(), - )); + let platform_re = r"(?x) + ( # We capture the group before the platform + (?:cpython|pypy) # Python implementation + - + \d+\.\d+ # Major and minor version + (?: # The patch version is handled separately + \. + (?: + \[X\] # A previously filtered patch version [X] + | # OR + \d+ # An actual patch version + ) + )? # (we allow the patch version to be missing entirely, e.g., in a request) + [a-z]? # Pre-release letter + (?: + \+[a-z]+ # An optional variant variant, such as `+free-threaded + )? + ) + - + [a-z0-9]+ # Operating system (e.g., 'macos') + - + [a-z0-9_]+ # Architecture (e.g., 'aarch64') + - + [a-z]+ # Libc (e.g., 'none') +"; + self.filters + .push((platform_re.to_string(), "$1-[PLATFORM]".to_string())); self }