Skip to content

Commit b88612d

Browse files
committed
on Windows, remove UNC prefix
1 parent 604e91b commit b88612d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nextest-runner/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ windows = { version = "0.42.0", features = [
9191
"Win32_System_JobObjects",
9292
] }
9393
win32job = "1.0.2"
94+
dunce = "1.0.3"
9495

9596
[dev-dependencies]
9697
color-eyre = { version = "0.6.2", default-features = false }

nextest-runner/src/cargo_config.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,24 @@ pub(crate) fn relative_dir_for(config_path: &Utf8Path) -> Option<&Utf8Path> {
548548
// Need to call parent() twice here, since in Cargo land relative means relative to the *parent*
549549
// of the directory the config is in. First parent() gets the directory the config is in, and
550550
// the second one gets the parent of that.
551-
config_path.parent()?.parent()
551+
let relative_dir = config_path.parent()?.parent()?;
552+
553+
// On Windows, remove the UNC prefix since Cargo does so as well.
554+
Some(strip_unc_prefix(relative_dir))
555+
}
556+
557+
#[cfg(windows)]
558+
#[inline]
559+
fn strip_unc_prefix(path: &Utf8Path) -> &Utf8Path {
560+
dunce::simplified(path.as_std_path())
561+
.try_into()
562+
.expect("stripping verbatim components from a UTF-8 path should result in a UTF-8 path")
563+
}
564+
565+
#[cfg(not(windows))]
566+
#[inline]
567+
fn strip_unc_prefix(path: &Utf8Path) -> &Utf8Path {
568+
path
552569
}
553570

554571
#[derive(Clone, Deserialize, Debug)]

0 commit comments

Comments
 (0)