diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 550f3c4..a0cccb3 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -179,26 +179,6 @@ impl TestContext { /// Initialize a sample project for pre-commit. pub fn init_project(&self) { - // TODO: Clone some repositories used in the tests. - // if !self.cache_dir.join("pre-commit-hooks") { - // Command::new("git") - // .arg("clone") - // .arg("https://github.com/pre-commit/pre-commit-hooks") - // .arg("--depth=1") - // .arg("--branch=v5.0.0") - // .current_dir(&self.cache_dir) - // .assert() - // .success(); - // } - // - // fs_extra::dir::copy( - // self.cache_dir.join("pre-commit-hooks"), - // self.home_dir.join("pre-commit-hooks"), - // &fs_extra::dir::CopyOptions::new(), - // )?; - - // Write some common files. - Command::new("git") .arg("init") .current_dir(&self.temp_dir) @@ -260,6 +240,8 @@ pub const INSTA_FILTERS: &[(&str, &str)] = &[ r"Caused by: .* \(os error 2\)", "Caused by: No such file or directory (os error 2)", ), + // Time seconds + (r"(\d+\.)?\d+s", "[TIME]"), ]; #[allow(unused_macros)] diff --git a/tests/run.rs b/tests/run.rs index 1ecf26a..9ca19d5 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -634,19 +634,25 @@ fn staged_files_only() -> Result<()> { .child("file.txt") .write_str("Hello world again!")?; - cmd_snapshot!(context.filters(), context.run(), @r#" + let filters: Vec<_> = context + .filters() + .into_iter() + .chain([(r"/\d+-\d+.patch", "/[TIME]-[PID].patch")]) + .collect(); + + cmd_snapshot!(filters, context.run(), @r#" success: true exit_code: 0 ----- stdout ----- trailing-whitespace......................................................Passed - hook id: trailing-whitespace - - duration: 0.03s + - duration: [TIME] Hello, world! ----- stderr ----- - Non-staged changes detected, saving to `[HOME]/1732196801370-22887.patch` + Non-staged changes detected, saving to `[HOME]/[TIME]-[PID].patch` - Restored working tree changes from `[HOME]/1732196801370-22887.patch` + Restored working tree changes from `[HOME]/[TIME]-[PID].patch` "#); let content = context.read("file.txt");