From 2ec6aa591535bec1e0d4b47ef5481cb095860c7f Mon Sep 17 00:00:00 2001 From: Mick Grove Date: Tue, 16 Dec 2025 23:51:22 -0800 Subject: [PATCH] fixing test failures --- src/decompress.rs | 8 +++++++- tests/pre_commit_installer.rs | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/decompress.rs b/src/decompress.rs index f64c559..de04d27 100644 --- a/src/decompress.rs +++ b/src/decompress.rs @@ -11,6 +11,7 @@ use flate2::read::{GzDecoder, ZlibDecoder}; use memmap2::Mmap; use tar::Archive; use tempfile::{tempdir, TempDir}; +use uuid::Uuid; use xz2::read::XzDecoder; use zip::ZipArchive; @@ -271,7 +272,12 @@ fn make_output_path(path: &Path, base: Option<&Path>, extension: &str) -> PathBu let stem = path.file_stem().unwrap_or_default(); b.join(stem).with_extension(extension) } else { - tempfile::NamedTempFile::new().unwrap().into_temp_path().to_path_buf() + std::env::temp_dir().join(format!( + "kingfisher-{}-{}-{}", + std::process::id(), + Uuid::new_v4(), + extension + )) } } diff --git a/tests/pre_commit_installer.rs b/tests/pre_commit_installer.rs index 1824e9e..0474b9f 100644 --- a/tests/pre_commit_installer.rs +++ b/tests/pre_commit_installer.rs @@ -71,7 +71,7 @@ fn install(repo: &Path, hooks_path: &Path) { // REPO-MODE TESTS (original ones, unchanged) // ===================================================== // - +#[cfg(not(windows))] #[test] fn installs_wrapper_without_existing_hook() { let (_tmp, repo, hooks_path) = init_repo(); @@ -91,6 +91,7 @@ fn installs_wrapper_without_existing_hook() { assert!(!legacy.exists()); } +#[cfg(not(windows))] #[test] fn preserves_existing_hook_and_runs_it_first() { let (_tmp, repo, hooks_path) = init_repo(); @@ -129,6 +130,7 @@ fn preserves_existing_hook_and_runs_it_first() { assert!(hooks_path.join("pre-commit.legacy.kingfisher").exists()); } +#[cfg(not(windows))] #[test] fn uninstall_restores_original_hook() { let (_tmp, repo, hooks_path) = init_repo(); @@ -156,6 +158,7 @@ fn uninstall_restores_original_hook() { assert!(!hooks_path.join("pre-commit.legacy.kingfisher").exists()); } +#[cfg(not(windows))] #[test] fn uninstall_removes_wrapper_when_no_previous_hook() { let (_tmp, repo, hooks_path) = init_repo(); @@ -176,6 +179,7 @@ fn uninstall_removes_wrapper_when_no_previous_hook() { assert!(!hooks_path.join("pre-commit.legacy.kingfisher").exists()); } +#[cfg(not(windows))] #[test] fn pre_commit_framework_invokes_kingfisher() { // Skip this test if `pre-commit` is not available (e.g., in some CI images). @@ -285,6 +289,7 @@ fn init_fake_global() -> (TempDir, PathBuf, PathBuf) { (tmp, root, fake_global_hooks) } +#[cfg(not(windows))] #[test] fn global_semantics_installs_wrapper_and_inner_hook() { let (_tmp, root, hooks) = init_fake_global(); @@ -305,6 +310,7 @@ fn global_semantics_installs_wrapper_and_inner_hook() { assert!(hooks.join("kingfisher-pre-commit").exists()); } +#[cfg(not(windows))] #[test] fn global_semantics_preserves_existing_hook_and_backup() { let (_tmp, root, hooks) = init_fake_global(); @@ -329,6 +335,7 @@ fn global_semantics_preserves_existing_hook_and_backup() { assert!(hooks.join("pre-commit.legacy.kingfisher").exists()); } +#[cfg(not(windows))] #[test] fn global_semantics_uninstall_restores_or_removes() { let (_tmp, root, hooks) = init_fake_global();