diff --git a/crates/socket-patch-core/src/patch/redirect/upstream/uv.rs b/crates/socket-patch-core/src/patch/redirect/upstream/uv.rs index 1404977a4..c7358e1bc 100644 --- a/crates/socket-patch-core/src/patch/redirect/upstream/uv.rs +++ b/crates/socket-patch-core/src/patch/redirect/upstream/uv.rs @@ -2378,20 +2378,37 @@ mod tests { let paths = |files: Vec<(String, toml_edit::Table)>| -> Vec { files.into_iter().map(|(path, _)| path).collect() }; - let dirs = - std::env::join_paths([root.join("dirs1"), root.join("dirs2"), root.join("dirs3")]) - .unwrap(); - let var = env(vec![ + // The display string of `//uv/uv.toml` as + // `global_uv_settings` builds it, with native separators. + let uv_toml = |dir: &str| { + dir.split('/') + .fold(root.to_path_buf(), |path, part| path.join(part)) + .join("uv") + .join("uv.toml") + .display() + .to_string() + }; + let mut pairs = vec![ ("XDG_CONFIG_HOME", root.join("xdg")), ("HOME", root.join("home")), - ("XDG_CONFIG_DIRS", dirs.into()), - ]); + ]; + let mut expected = vec![uv_toml("xdg")]; + // `$XDG_CONFIG_DIRS` splits on `:` as on Unix, which would also + // split a Windows drive letter, so only Unix checks the system file. + if cfg!(unix) { + let dirs = format!( + "{}:{}:{}", + root.join("dirs1").display(), + root.join("dirs2").display(), + root.join("dirs3").display() + ); + pairs.push(("XDG_CONFIG_DIRS", dirs.into())); + expected.push(uv_toml("dirs2")); + } + let var = env(pairs); assert_eq!( paths(global_uv_settings(&var, false).await.unwrap()), - [ - root.join("xdg/uv/uv.toml").display().to_string(), - root.join("dirs2/uv/uv.toml").display().to_string(), - ] + expected ); // A relative XDG_CONFIG_HOME counts as unset. let var = env(vec![ @@ -2400,10 +2417,7 @@ mod tests { ("XDG_CONFIG_DIRS", root.join("none")), ]); let found = paths(global_uv_settings(&var, false).await.unwrap()); - assert_eq!( - found[0], - root.join("home/.config/uv/uv.toml").display().to_string() - ); + assert_eq!(found[0], uv_toml("home/.config")); // Windows reads %APPDATA% and %PROGRAMDATA%. write("appdata/uv/uv.toml", "no-build = true\n"); let var = env(vec![ @@ -2412,10 +2426,7 @@ mod tests { ]); assert_eq!( paths(global_uv_settings(&var, true).await.unwrap()), - [ - root.join("appdata/uv/uv.toml").display().to_string(), - root.join("dirs3/uv/uv.toml").display().to_string(), - ] + [uv_toml("appdata"), uv_toml("dirs3")] ); // Like uv, the system entries end at the first empty one, and a // directory named `uv.toml` is passed over.