From 58cf93a219c0edb56e92a378b963ef9408faca5a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 29 Nov 2024 14:23:12 -0500 Subject: [PATCH] Un-gate `--emit-marker-expression` tests via `--python-platform` (#9528) These are tedious to update on non-Linux, but I think we can just use `--python-platform` to make them work on all platforms. --- crates/uv/tests/it/pip_compile.rs | 45 +++++++++++-------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 463b73369276..a9747974ac9d 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -10925,13 +10925,7 @@ fn dynamic_dependencies() -> Result<()> { /// This tests the marker expressions emitted when depending on a package with /// exciting markers like 'anyio'. -/// -/// NOTE: This test runs on `linux` only because some of `anyio`'s markers -/// involve querying the specific platform being used to run `uv pip compile`. -/// Since this test was developed on Linux, the marker expression generated is -/// coupled with the Linux platform. Other tests for other platforms could be -/// added. -#[cfg(all(target_os = "linux", feature = "python-patch"))] +#[cfg(feature = "python-patch")] #[test] fn emit_marker_expression_exciting_linux() -> Result<()> { let context = TestContext::new("3.12.6"); @@ -10941,12 +10935,14 @@ fn emit_marker_expression_exciting_linux() -> Result<()> { uv_snapshot!(context .pip_compile() .arg("requirements.in") + .arg("--python-platform") + .arg("linux") .arg("--emit-marker-expression"), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-marker-expression + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-platform linux --emit-marker-expression # Pinned dependencies known to be valid for: # python_full_version == '3.12.6' and platform_python_implementation == 'CPython' and platform_system == 'Linux' anyio==4.3.0 @@ -10965,10 +10961,7 @@ fn emit_marker_expression_exciting_linux() -> Result<()> { /// This tests that the marker expression emitted accounts for markers directly /// in `requirements.in`. -/// -/// NOTE: This test runs on `linux` only because it requires that `sys_platform -/// == 'linux'` evaluates to `true`. -#[cfg(all(target_os = "linux", feature = "python-patch"))] +#[cfg(feature = "python-patch")] #[test] fn emit_marker_expression_direct() -> Result<()> { let context = TestContext::new("3.12.6"); @@ -10978,12 +10971,14 @@ fn emit_marker_expression_direct() -> Result<()> { uv_snapshot!(context .pip_compile() .arg("requirements.in") + .arg("--python-platform") + .arg("linux") .arg("--emit-marker-expression"), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-marker-expression + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-platform linux --emit-marker-expression # Pinned dependencies known to be valid for: # python_full_version == '3.12.6' and platform_python_implementation == 'CPython' and platform_system == 'Linux' and sys_platform == 'linux' anyio==4.3.0 @@ -11006,12 +11001,6 @@ fn emit_marker_expression_direct() -> Result<()> { /// Linux, this dependency is ignored. But the marker expression generated must /// have `sys_platform == 'Linux'`, since the locked set of packages might be /// different (and indeed are different) on other platforms. -/// -/// NOTE: This test runs on `linux` because it requires that `sys_platform -/// == 'macos'` evaluates to `false`. While this technically only requires -/// `not(target_os = "macos")`, the marker expression generated during test -/// development was on Linux. So we require Linux. -#[cfg(target_os = "linux")] #[test] fn emit_marker_expression_conditional() -> Result<()> { let context = TestContext::new("3.12"); @@ -11021,12 +11010,14 @@ fn emit_marker_expression_conditional() -> Result<()> { uv_snapshot!(context .pip_compile() .arg("requirements.in") + .arg("--python-platform") + .arg("linux") .arg("--emit-marker-expression"), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-marker-expression + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-platform linux --emit-marker-expression # Pinned dependencies known to be valid for: # sys_platform == 'linux' @@ -11040,15 +11031,7 @@ fn emit_marker_expression_conditional() -> Result<()> { /// This tests the marker expressions emitted when depending on a package with /// a non-pypy dependency. Specifically, `pendulum` depends on `time-machine`, /// but not when using pypy. -/// -/// NOTE: This test runs on `linux` because it was written on Linux. While the -/// marker expression itself doesn't have anything in it that couples it to -/// Linux, it is possible for the resolution to change on other platforms. For -/// example, on Windows, the `tzdata` dependency is excluded. (It's actually -/// not clear why. The `tzdata` dependency appears to be an unconditional -/// dependency. And if anything, I'd expect it to be included on Windows and -/// excluded everywhere else... Odd.) -#[cfg(all(target_os = "linux", feature = "python-patch"))] +#[cfg(feature = "python-patch")] #[test] fn emit_marker_expression_pypy() -> Result<()> { let context = TestContext::new("3.12.6"); @@ -11058,12 +11041,14 @@ fn emit_marker_expression_pypy() -> Result<()> { uv_snapshot!(context .pip_compile() .arg("requirements.in") + .arg("--python-platform") + .arg("linux") .arg("--emit-marker-expression"), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-marker-expression + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-platform linux --emit-marker-expression # Pinned dependencies known to be valid for: # python_full_version == '3.12.6' and implementation_name == 'cpython' pendulum==3.0.0