Compare simplified paths in Windows exclusion tests (#5525)

## Summary

Closes https://github.com/astral-sh/uv/issues/5521.
This commit is contained in:
Charlie Marsh 2024-07-28 17:26:46 -04:00 committed by GitHub
parent efbc9fb78d
commit 2d5c166642
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 80 additions and 1 deletions

View file

@ -1058,7 +1058,7 @@ fn is_excluded_from_workspace(
{ {
let excluded_root = excluded_root let excluded_root = excluded_root
.map_err(|err| WorkspaceError::Glob(absolute_glob.to_string(), err))?; .map_err(|err| WorkspaceError::Glob(absolute_glob.to_string(), err))?;
if excluded_root == project_path { if excluded_root == project_path.simplified() {
return Ok(true); return Ok(true);
} }
} }

View file

@ -4139,3 +4139,82 @@ fn lock_unsafe_lowest() -> Result<()> {
Ok(()) Ok(())
} }
/// Lock a package that's excluded from the parent workspace, but depends on that parent.
#[test]
fn lock_exclusion() -> Result<()> {
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 = []
[tool.uv.workspace]
members = []
exclude = ["child"]
"#,
)?;
let child = context.temp_dir.child("child");
fs_err::create_dir_all(&child)?;
let pyproject_toml = child.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "child"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["project"]
[tool.uv.sources]
project = { path = ".." }
"#,
)?;
uv_snapshot!(context.filters(), context.lock().current_dir(&child), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: `uv lock` is experimental and may change without warning
Using Python 3.12.[X] interpreter at: [PYTHON-3.12]
warning: `uv.sources` is experimental and may change without warning
Resolved 2 packages in [TIME]
"###);
let lock = fs_err::read_to_string(child.join("uv.lock")).unwrap();
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(
lock, @r###"
version = 1
requires-python = ">=3.12"
exclude-newer = "2024-03-25 00:00:00 UTC"
[[distribution]]
name = "child"
version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "project" },
]
[[distribution]]
name = "project"
version = "0.1.0"
source = { directory = "../" }
"###
);
});
Ok(())
}