Fix cache-prune-test to work outside the git repository (#4375)

## Summary

Make the git commit/date part of the version string matched in
cache_prune optional, so that the test also works correctly when uv is
built from an unpacked release tarball rather than a git repository.

Fixes #4374

## Test Plan

Ran `cargo test` inside the git repository and inside unpacked archive
for `0.2.12` release with the patch applied on top.
This commit is contained in:
Michał Górny 2024-06-18 09:15:40 +02:00 committed by GitHub
parent c996e8e3f3
commit a193834813
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,7 +71,10 @@ fn prune_no_op() -> Result<()> {
let filters: Vec<_> = context
.filters()
.into_iter()
.chain([(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)")])
.chain([(
r"uv \d+\.\d+\.\d+( \(.*\))?",
r"uv [VERSION] ([COMMIT] DATE)",
)])
.collect();
uv_snapshot!(filters, prune_command(&context).arg("--verbose"), @r###"
@ -109,7 +112,10 @@ fn prune_stale_directory() -> Result<()> {
let filters: Vec<_> = context
.filters()
.into_iter()
.chain([(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)")])
.chain([(
r"uv \d+\.\d+\.\d+( \(.*\))?",
r"uv [VERSION] ([COMMIT] DATE)",
)])
.collect();
uv_snapshot!(filters, prune_command(&context).arg("--verbose"), @r###"
@ -149,7 +155,10 @@ fn prune_stale_symlink() -> Result<()> {
.filters()
.into_iter()
.chain([
(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)"),
(
r"uv \d+\.\d+\.\d+( \(.*\))?",
r"uv [VERSION] ([COMMIT] DATE)",
),
// The cache entry does not have a stable key, so we filter it out
(
r"\[CACHE_DIR\](\\|\/)(.+)(\\|\/).*",