From 120b7c54ca29c904cc2112c7966e815324fe4ebf Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Wed, 5 Feb 2025 14:33:23 -0500 Subject: [PATCH 1/2] check in tests from other pr --- crates/uv/tests/it/sync.rs | 218 +++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 44e99803bfeab..822bacdb430c5 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -1817,6 +1817,224 @@ fn sync_non_existent_default_group() -> Result<()> { Ok(()) } + +#[test] +fn sync_corner_groups() -> Result<()> { + // Testing a bunch of random corner cases of flags so their behaviour is tracked. + // It's fine if we decide we want to support these later! + let context = TestContext::new("3.12"); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r#" + [project] + name = "project" + version = "0.1.0" + requires-python = ">=3.12" + dependencies = ["typing-extensions"] + + [dependency-groups] + dev = ["iniconfig"] + foo = ["sniffio"] + bar = ["requests"] + "#, + )?; + + context.lock().assert().success(); + + // --no-dev and --only-dev should error + // (This one could be made to work with overloading) + uv_snapshot!(context.filters(), context.sync() + .arg("--no-dev") + .arg("--only-dev"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--no-dev' cannot be used with '--only-dev' + + Usage: uv sync --cache-dir [CACHE_DIR] --no-dev --exclude-newer + + For more information, try '--help'. + "); + + // --dev and --only-group should error if they don't match + uv_snapshot!(context.filters(), context.sync() + .arg("--dev") + .arg("--only-group").arg("bar"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--dev' cannot be used with '--only-group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --exclude-newer + + For more information, try '--help'. + "); + + // --dev and --only-group should error even if it's dev still + // (This one could be made to work the same as --dev --only-dev) + uv_snapshot!(context.filters(), context.sync() + .arg("--dev") + .arg("--only-group").arg("dev"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--dev' cannot be used with '--only-group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --exclude-newer + + For more information, try '--help'. + "); + + // --group and --only-dev should error if they don't match + // (This one could be made to work the same as --dev --only-dev) + uv_snapshot!(context.filters(), context.sync() + .arg("--only-dev") + .arg("--group").arg("bar"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--only-dev' cannot be used with '--group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --only-dev --exclude-newer + + For more information, try '--help'. + "); + + // --group and --only-dev should error even if it's dev still + // (This one could be made to work the same as --dev --only-dev) + uv_snapshot!(context.filters(), context.sync() + .arg("--only-dev") + .arg("--group").arg("dev"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--only-dev' cannot be used with '--group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --only-dev --exclude-newer + + For more information, try '--help'. + "); + + // --all-groups and --only-dev should error + uv_snapshot!(context.filters(), context.sync() + .arg("--all-groups") + .arg("--only-dev"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--all-groups' cannot be used with '--only-dev' + + Usage: uv sync --cache-dir [CACHE_DIR] --all-groups --exclude-newer + + For more information, try '--help'. + "); + + // --all-groups and --only-group should error + uv_snapshot!(context.filters(), context.sync() + .arg("--all-groups") + .arg("--only-group").arg("bar"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--all-groups' cannot be used with '--only-group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --all-groups --exclude-newer + + For more information, try '--help'. + "); + + // --group and --only-group should error if they name disjoint things + uv_snapshot!(context.filters(), context.sync() + .arg("--group").arg("foo") + .arg("--only-group").arg("bar"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--group ' cannot be used with '--only-group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --group --exclude-newer + + For more information, try '--help'. + "); + + // --group and --only-group should error if they name same things + // (This one would be fair to allow, but... is it worth it?) + uv_snapshot!(context.filters(), context.sync() + .arg("--group").arg("foo") + .arg("--only-group").arg("foo"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: the argument '--group ' cannot be used with '--only-group ' + + Usage: uv sync --cache-dir [CACHE_DIR] --group --exclude-newer + + For more information, try '--help'. + "); + + // --all-groups and --no-default-groups is redundant but should be --all-groups + uv_snapshot!(context.filters(), context.sync() + .arg("--all-groups") + .arg("--no-default-groups"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 9 packages in [TIME] + Prepared 8 packages in [TIME] + Installed 8 packages in [TIME] + + certifi==2024.2.2 + + charset-normalizer==3.3.2 + + idna==3.6 + + iniconfig==2.0.0 + + requests==2.31.0 + + sniffio==1.3.1 + + typing-extensions==4.10.0 + + urllib3==2.2.1 + "); + + // --dev --only-dev should saturate as --only-dev + uv_snapshot!(context.filters(), context.sync() + .arg("--dev") + .arg("--only-dev"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 9 packages in [TIME] + Uninstalled 7 packages in [TIME] + - certifi==2024.2.2 + - charset-normalizer==3.3.2 + - idna==3.6 + - requests==2.31.0 + - sniffio==1.3.1 + - typing-extensions==4.10.0 + - urllib3==2.2.1 + "); + Ok(()) +} + #[test] fn sync_default_groups() -> Result<()> { let context = TestContext::new("3.12"); From 223d998c2434b61d509967d45d5e0edb0a2e8dcc Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Wed, 5 Feb 2025 14:40:17 -0500 Subject: [PATCH 2/2] regenerate snapshots on actual main --- crates/uv/tests/it/sync.rs | 96 +++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 822bacdb430c5..868aa26d49611 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -1864,15 +1864,15 @@ fn sync_corner_groups() -> Result<()> { .arg("--dev") .arg("--only-group").arg("bar"), @r" success: false - exit_code: 2 + exit_code: 101 ----- stdout ----- ----- stderr ----- - error: the argument '--dev' cannot be used with '--only-group ' - - Usage: uv sync --cache-dir [CACHE_DIR] --exclude-newer - - For more information, try '--help'. + thread 'main2' panicked at crates/uv-configuration/src/dev.rs:247:17: + internal error: entered unreachable code: cannot specify both `--dev` and `--only-group` + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + thread 'main' panicked at [WORKSPACE]/crates/uv/src/lib.rs:1907:10: + Tokio executor failed, was there a panic?: Any { .. } "); // --dev and --only-group should error even if it's dev still @@ -1881,15 +1881,15 @@ fn sync_corner_groups() -> Result<()> { .arg("--dev") .arg("--only-group").arg("dev"), @r" success: false - exit_code: 2 + exit_code: 101 ----- stdout ----- ----- stderr ----- - error: the argument '--dev' cannot be used with '--only-group ' - - Usage: uv sync --cache-dir [CACHE_DIR] --exclude-newer - - For more information, try '--help'. + thread 'main2' panicked at crates/uv-configuration/src/dev.rs:247:17: + internal error: entered unreachable code: cannot specify both `--dev` and `--only-group` + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + thread 'main' panicked at [WORKSPACE]/crates/uv/src/lib.rs:1907:10: + Tokio executor failed, was there a panic?: Any { .. } "); // --group and --only-dev should error if they don't match @@ -1898,15 +1898,15 @@ fn sync_corner_groups() -> Result<()> { .arg("--only-dev") .arg("--group").arg("bar"), @r" success: false - exit_code: 2 + exit_code: 101 ----- stdout ----- ----- stderr ----- - error: the argument '--only-dev' cannot be used with '--group ' - - Usage: uv sync --cache-dir [CACHE_DIR] --only-dev --exclude-newer - - For more information, try '--help'. + thread 'main2' panicked at crates/uv-configuration/src/dev.rs:235:17: + internal error: entered unreachable code: cannot specify both `--only-dev` and `--group` + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + thread 'main' panicked at [WORKSPACE]/crates/uv/src/lib.rs:1907:10: + Tokio executor failed, was there a panic?: Any { .. } "); // --group and --only-dev should error even if it's dev still @@ -1915,31 +1915,36 @@ fn sync_corner_groups() -> Result<()> { .arg("--only-dev") .arg("--group").arg("dev"), @r" success: false - exit_code: 2 + exit_code: 101 ----- stdout ----- ----- stderr ----- - error: the argument '--only-dev' cannot be used with '--group ' - - Usage: uv sync --cache-dir [CACHE_DIR] --only-dev --exclude-newer - - For more information, try '--help'. + thread 'main2' panicked at crates/uv-configuration/src/dev.rs:235:17: + internal error: entered unreachable code: cannot specify both `--only-dev` and `--group` + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + thread 'main' panicked at [WORKSPACE]/crates/uv/src/lib.rs:1907:10: + Tokio executor failed, was there a panic?: Any { .. } "); // --all-groups and --only-dev should error uv_snapshot!(context.filters(), context.sync() .arg("--all-groups") .arg("--only-dev"), @r" - success: false - exit_code: 2 + success: true + exit_code: 0 ----- stdout ----- ----- stderr ----- - error: the argument '--all-groups' cannot be used with '--only-dev' - - Usage: uv sync --cache-dir [CACHE_DIR] --all-groups --exclude-newer - - For more information, try '--help'. + Resolved 9 packages in [TIME] + Prepared 7 packages in [TIME] + Installed 7 packages in [TIME] + + certifi==2024.2.2 + + charset-normalizer==3.3.2 + + idna==3.6 + + iniconfig==2.0.0 + + requests==2.31.0 + + sniffio==1.3.1 + + urllib3==2.2.1 "); // --all-groups and --only-group should error @@ -2001,16 +2006,17 @@ fn sync_corner_groups() -> Result<()> { ----- stderr ----- Resolved 9 packages in [TIME] - Prepared 8 packages in [TIME] - Installed 8 packages in [TIME] - + certifi==2024.2.2 - + charset-normalizer==3.3.2 - + idna==3.6 - + iniconfig==2.0.0 - + requests==2.31.0 - + sniffio==1.3.1 + Prepared 1 package in [TIME] + Uninstalled 7 packages in [TIME] + Installed 1 package in [TIME] + - certifi==2024.2.2 + - charset-normalizer==3.3.2 + - idna==3.6 + - iniconfig==2.0.0 + - requests==2.31.0 + - sniffio==1.3.1 + typing-extensions==4.10.0 - + urllib3==2.2.1 + - urllib3==2.2.1 "); // --dev --only-dev should saturate as --only-dev @@ -2023,14 +2029,10 @@ fn sync_corner_groups() -> Result<()> { ----- stderr ----- Resolved 9 packages in [TIME] - Uninstalled 7 packages in [TIME] - - certifi==2024.2.2 - - charset-normalizer==3.3.2 - - idna==3.6 - - requests==2.31.0 - - sniffio==1.3.1 + Uninstalled 1 package in [TIME] + Installed 1 package in [TIME] + + iniconfig==2.0.0 - typing-extensions==4.10.0 - - urllib3==2.2.1 "); Ok(()) }