forked from mirrors/kingfisher
fixing test failures
This commit is contained in:
parent
e3cc9bfda1
commit
2ec6aa5915
2 changed files with 15 additions and 2 deletions
|
|
@ -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
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue