Skip to content

Commit

Permalink
Fix cache-prune-test to work outside the git repository (#4375)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
mgorny authored Jun 18, 2024
1 parent c996e8e commit a193834
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/uv/tests/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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###"
Expand Down Expand Up @@ -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###"
Expand Down Expand Up @@ -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\](\\|\/)(.+)(\\|\/).*",
Expand Down

0 comments on commit a193834

Please sign in to comment.