Skip to content

Commit e5e562e

Browse files
committed
add new test
1 parent 177d9d8 commit e5e562e

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

git2-hooks/src/lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,39 @@ exit 0
309309
assert!(res.is_ok());
310310
}
311311

312+
#[test]
313+
fn test_hook_with_missing_shebang() {
314+
const TEXT: &str = "Hello, world!";
315+
316+
let (_td, repo) = repo_init();
317+
318+
let hook = b"echo \"$@\"\nexit 42";
319+
320+
create_hook(&repo, HOOK_PRE_COMMIT, hook);
321+
322+
let hook =
323+
HookPaths::new(&repo, None, HOOK_PRE_COMMIT).unwrap();
324+
325+
assert!(hook.found());
326+
327+
let result = hook.run_hook(&[TEXT]).unwrap();
328+
329+
if let HookResult::RunNotSuccessful {
330+
code,
331+
stdout,
332+
stderr,
333+
hook: h,
334+
} = result
335+
{
336+
assert_eq!(code, Some(42));
337+
assert_eq!(stdout.as_str().trim_end(), TEXT);
338+
assert!(stderr.is_empty());
339+
assert_eq!(h, hook.hook);
340+
} else {
341+
panic!("run_hook should've failed");
342+
}
343+
}
344+
312345
#[test]
313346
fn test_no_hook_found() {
314347
let (_td, repo) = repo_init();

0 commit comments

Comments
 (0)