Skip to content

Commit

Permalink
Filter counts
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 28, 2025
1 parent 9014db8 commit b749ee4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
12 changes: 8 additions & 4 deletions crates/uv/tests/it/cache_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ fn clean_package_pypi() -> Result<()> {
.filters()
.into_iter()
.chain([
// The cache entry does not have a stable key, so we filter it out
// The cache entry does not have a stable key, so we filter it out.
(
r"\[CACHE_DIR\](\\|\/)(.+)(\\|\/).*",
"[CACHE_DIR]/$2/[ENTRY]",
),
// The file count varies by operating system, so we filter it out.
("Removed \\d+ files?", "Removed [N] files"),
])
.collect();

Expand All @@ -79,7 +81,7 @@ fn clean_package_pypi() -> Result<()> {
----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Removing dangling cache entry: [CACHE_DIR]/archive-v0/[ENTRY]
Removed 12 files ([SIZE])
Removed [N] files ([SIZE])
"###);

// Assert that the `.rkyv` file is removed for `iniconfig`.
Expand Down Expand Up @@ -136,11 +138,13 @@ fn clean_package_index() -> Result<()> {
.filters()
.into_iter()
.chain([
// The cache entry does not have a stable key, so we filter it out
// The cache entry does not have a stable key, so we filter it out.
(
r"\[CACHE_DIR\](\\|\/)(.+)(\\|\/).*",
"[CACHE_DIR]/$2/[ENTRY]",
),
// The file count varies by operating system, so we filter it out.
("Removed \\d+ files?", "Removed [N] files"),
])
.collect();

Expand All @@ -152,7 +156,7 @@ fn clean_package_index() -> Result<()> {
----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Removing dangling cache entry: [CACHE_DIR]/archive-v0/[ENTRY]
Removed 12 files ([SIZE])
Removed [N] files ([SIZE])
"###);

// Assert that the `.rkyv` file is removed for `iniconfig`.
Expand Down
75 changes: 36 additions & 39 deletions crates/uv/tests/it/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,14 +1418,18 @@ fn install_url_source_dist_cached() -> Result<()> {
// Clear the cache, then re-run the installation in a new virtual environment.
context.reset_venv();

uv_snapshot!(context.clean()
.arg("source_distribution"), @r###"
let filters = std::iter::once(("Removed \\d+ files?", "Removed [N] files"))
.chain(context.filters())
.collect::<Vec<_>>();
uv_snapshot!(
filters,
context.clean().arg("source_distribution"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Removed 19 files ([SIZE])
Removed [N] files ([SIZE])
"###
);

Expand Down Expand Up @@ -1600,27 +1604,17 @@ fn install_registry_source_dist_cached() -> Result<()> {
// Clear the cache, then re-run the installation in a new virtual environment.
context.reset_venv();

let filters: Vec<(&str, &str)> = if cfg!(windows) {
// On Windows, the number of files removed is different.
[("Removed 13 files", "Removed 14 files")]
.into_iter()
.chain(context.filters())
.collect()
} else {
// For some Linux distributions, like Gentoo, the number of files removed is different.
[("Removed 12 files", "Removed 14 files")]
.into_iter()
.chain(context.filters())
.collect()
};
let filters = std::iter::once(("Removed \\d+ files?", "Removed [N] files"))
.chain(context.filters())
.collect::<Vec<_>>();
uv_snapshot!(filters, context.clean()
.arg("source_distribution"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Removed 20 files ([SIZE])
Removed [N] files ([SIZE])
"###
);

Expand Down Expand Up @@ -1710,14 +1704,18 @@ fn install_path_source_dist_cached() -> Result<()> {
// Clear the cache, then re-run the installation in a new virtual environment.
context.reset_venv();

uv_snapshot!(context.clean()
.arg("source-distribution"), @r###"
let filters = std::iter::once(("Removed \\d+ files?", "Removed [N] files"))
.chain(context.filters())
.collect::<Vec<_>>();
uv_snapshot!(
filters,
context.clean().arg("source-distribution"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Removed 19 files ([SIZE])
Removed [N] files ([SIZE])
"###
);

Expand Down Expand Up @@ -1800,23 +1798,18 @@ fn install_path_built_dist_cached() -> Result<()> {
// Clear the cache, then re-run the installation in a new virtual environment.
context.reset_venv();

let filters = if cfg!(windows) {
// We do not display sizes on Windows
[("Removed 1 file", "Removed 1 file ([SIZE])")]
.into_iter()
.chain(context.filters())
.collect()
} else {
context.filters()
};
uv_snapshot!(filters, context.clean()
.arg("tomli"), @r###"
let filters = std::iter::once(("Removed \\d+ files?", "Removed [N] files"))
.chain(context.filters())
.collect::<Vec<_>>();
uv_snapshot!(
filters,
context.clean().arg("tomli"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Removed 11 files ([SIZE])
Removed [N] files ([SIZE])
"###
);

Expand Down Expand Up @@ -1849,15 +1842,15 @@ fn install_url_built_dist_cached() -> Result<()> {
let requirements_txt = context.temp_dir.child("requirements.txt");
requirements_txt.write_str("tqdm @ https://files.pythonhosted.org/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl")?;

let filters = if cfg!(windows) {
let context_filters = if cfg!(windows) {
[("warning: The package `tqdm` requires `colorama ; sys_platform == 'win32'`, but it's not installed\n", "")]
.into_iter()
.chain(context.filters())
.collect()
} else {
context.filters()
};
uv_snapshot!(filters, context.pip_sync()
uv_snapshot!(context_filters, context.pip_sync()
.arg("requirements.txt")
.arg("--strict"), @r###"
success: true
Expand All @@ -1877,7 +1870,7 @@ fn install_url_built_dist_cached() -> Result<()> {
// Re-run the installation in a new virtual environment.
context.reset_venv();

uv_snapshot!(filters, context.pip_sync()
uv_snapshot!(context_filters, context.pip_sync()
.arg("requirements.txt")
.arg("--strict")
, @r###"
Expand All @@ -1897,18 +1890,22 @@ fn install_url_built_dist_cached() -> Result<()> {
// Clear the cache, then re-run the installation in a new virtual environment.
context.reset_venv();

uv_snapshot!(context.clean()
.arg("tqdm"), @r###"
let filters = std::iter::once(("Removed \\d+ files?", "Removed [N] files"))
.chain(context_filters.clone())
.collect::<Vec<_>>();
uv_snapshot!(
filters,
context.clean().arg("tqdm"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Removed 43 files ([SIZE])
Removed [N] files ([SIZE])
"###
);

uv_snapshot!(filters, context.pip_sync()
uv_snapshot!(context_filters, context.pip_sync()
.arg("requirements.txt")
.arg("--strict")
, @r###"
Expand Down

0 comments on commit b749ee4

Please sign in to comment.