File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 \" $@\" \n exit 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 ( ) ;
You can’t perform that action at this time.
0 commit comments