Skip to content

Commit

Permalink
Un-gate --emit-marker-expression tests via --python-platform (#9528)
Browse files Browse the repository at this point in the history
These are tedious to update on non-Linux, but I think we can just use
`--python-platform` to make them work on all platforms.
  • Loading branch information
charliermarsh authored Nov 29, 2024
1 parent 9864d23 commit 58cf93a
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -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'
Expand All @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit 58cf93a

Please sign in to comment.