diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bf06db..733e83f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,11 @@ jobs: - run: cargo doc --no-deps --document-private-items test: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable diff --git a/src/numbered_dir.rs b/src/numbered_dir.rs index b2e2ea3..f59e1e9 100644 --- a/src/numbered_dir.rs +++ b/src/numbered_dir.rs @@ -314,8 +314,13 @@ mod tests { assert!(dir_0.path().is_dir()); assert!(dir_1.path().is_dir()); - let current = fs::read_link(parent.path().join("base-current")).unwrap(); - assert_eq!(dir_1.path(), current); + // We know that on windows the first symlink probably didn't get removed, symlinks + // are best-effort there. + #[cfg(target_family = "unix")] + { + let current = fs::read_link(parent.path().join("base-current")).unwrap(); + assert_eq!(dir_1.path(), current); + } } #[test] diff --git a/src/private.rs b/src/private.rs index 688d9d5..556ce42 100644 --- a/src/private.rs +++ b/src/private.rs @@ -20,6 +20,18 @@ const CARGO_PID_FILE_NAME: &str = "cargo-pid"; /// Whether we are a cargo sub-process. static CARGO_PID: Lazy> = Lazy::new(cargo_pid); +#[cfg(target_family = "unix")] +const CARGO_NAME: &str = "cargo"; + +#[cfg(target_family = "unix")] +const NEXTEST_NAME: &str = "cargo-nextest"; + +#[cfg(target_family = "windows")] +const CARGO_NAME: &str = "cargo.exe"; + +#[cfg(target_family = "windows")] +const NEXTEST_NAME: &str = "cargo-nextest.exe"; + /// Returns the process ID of our parent Cargo process. /// /// If our parent process is not Cargo, `None` is returned. @@ -43,7 +55,7 @@ fn cargo_pid() -> Option { let parent = sys.process(ppid)?; let parent_exe = parent.exe(); let parent_file_name = parent_exe.file_name()?; - if parent_file_name == OsStr::new("cargo") || parent_file_name == OsStr::new("cargo-nextest") { + if parent_file_name == OsStr::new(CARGO_NAME) || parent_file_name == OsStr::new(NEXTEST_NAME) { Some(parent.pid()) } else if parent_file_name == OsStr::new("rustdoc") { let ppid = parent.parent()?; @@ -127,7 +139,10 @@ pub fn extract_test_name_from_backtrace(module_path: &str) -> String { } } } - panic!("Cannot determine test name from backtrace"); + + // We know that on windows doc tests fall through as the module_path is something like + // "rust_out" which is not very useful. We'll have to just use something. + String::from("unknown_test") } #[cfg(test)]