From d41ab0ef4db7c517c89ec5ec1637b9eae5a336ce Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 27 Mar 2024 13:04:50 -0400 Subject: [PATCH] uv/tests: add regression test for `echo pendulum | uv pip compile -` (#2693) I stumbled across this when writing tests for `--emit-marker-expressions`. Namely, I observed that in CI, the `tzdata` dependency of `pendulum` wasn't included in the `requirements.txt` output on Windows. @konstin [suggested] that this was a bug, so I've created a test for it. In particular, it looks like [`tzdata` is an unconditional dependency of `pendulum`][tzdata-unconditional]. [suggested]: https://github.com/astral-sh/uv/pull/2651#discussion_r1539722464 [tzdata-unconditional]: https://inspector.pypi.io/project/pendulum/3.0.0/packages/67/5e/e646afbd1632bfbacdae79289d7d5879efdeeb5f5e58327bc5c698731107/pendulum-3.0.0-cp310-none-win_amd64.whl/pendulum-3.0.0.dist-info/METADATA#line.12 --- crates/uv/tests/common/mod.rs | 4 ++++ crates/uv/tests/pip_compile.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/crates/uv/tests/common/mod.rs b/crates/uv/tests/common/mod.rs index 6755d8fec..b746eee1c 100644 --- a/crates/uv/tests/common/mod.rs +++ b/crates/uv/tests/common/mod.rs @@ -417,6 +417,10 @@ pub fn run_and_format<'a>( } } + // This is a heuristic filter meant to try and make *most* of our tests + // pass whether it's on Windows or Unix. In particular, there are some very + // common Windows-only dependencies that, when removed from a resolution, + // cause the set of dependencies to be the same across platforms. if cfg!(windows) && windows_filters { // The optional leading +/- is for install logs, the optional next line is for lock files let windows_only_deps = [ diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 8cc338610..f788e2bd2 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -6294,3 +6294,37 @@ fn emit_marker_expression_pypy() -> Result<()> { Ok(()) } + +#[test] +fn pendulum_no_tzdata_on_windows() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("pendulum")?; + + uv_snapshot!( + context.filters(), + windows_filters=false, + context.compile().arg("requirements.in"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z requirements.in + pendulum==3.0.0 + python-dateutil==2.9.0.post0 + # via + # pendulum + # time-machine + six==1.16.0 + # via python-dateutil + time-machine==2.14.1 + # via pendulum + tzdata==2024.1 + # via pendulum + + ----- stderr ----- + Resolved 5 packages in [TIME] + "###); + + Ok(()) +}