Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Run the hooks under every POSIX shell present
Only sh, dash, ksh and bash were tried, so busybox sh ran only where it
is /bin/sh, and mksh, yash, posh and zsh's sh mode never ran. Where sh
is a link to dash, the same shell ran twice. A shell reached by two
names now runs once, and the list is said so a run shows what it
covered.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0507-hooks.sh | 69 |
1 file changed, 45 insertions, 24 deletions
diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index 04f8490..b695e03 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -143,19 +143,40 @@ test_expect_success 'set up a cache of a scanned repository with a work tree' ' ' # The hooks are POSIX sh, so every case runs under each such shell that is -# here. Whatever a hook prints reaches the pusher, so each has to stay -# silent. +# here, once however many names reach it. Whatever a hook prints reaches the +# pusher, so each has to stay silent. shells= -for shell in sh dash ksh bash +shell_paths= +for shell in sh dash ksh mksh yash posh bash zsh busybox do - command -v $shell >/dev/null && shells="$shells $shell" + shell_path=$(command -v $shell) || continue + for seen in $shell_paths + do + test "$seen" -ef "$shell_path" && continue 2 + done + shell_paths="$shell_paths $shell_path" + shells="$shells $shell" done +say "running the hooks under$shells" for shell in $shells do + # zsh and busybox behave as sh only when asked to. + case $shell in + zsh) + run="zsh --emulate sh" + ;; + busybox) + run="busybox sh" + ;; + *) + run=$shell + ;; + esac + test_expect_success "a push drops its own pages and the index under $shell" ' fresh_slots && - (cd scan/a.git && $shell ../../cache-hook 2>../../err) && + (cd scan/a.git && $run ../../cache-hook 2>../../err) && test_must_be_empty err && cached_requests slots >left && test_grep "|/b.git/log/" left && @@ -171,7 +192,7 @@ do test_expect_success "a push drops the pages of a repository served without the suffix under $shell" ' rm -rf suffix-slots && cp -R suffix-pristine suffix-slots && - (cd scan/a.git && $shell ../../suffix-hook 2>../../err) && + (cd scan/a.git && $run ../../suffix-hook 2>../../err) && test_must_be_empty err && cached_requests suffix-slots >left && test_grep "|/b/log/0|" left && @@ -181,7 +202,7 @@ do test_expect_success "a push to a repository with a work tree drops its pages under $shell" ' rm -rf worktree-slots && cp -R worktree-pristine worktree-slots && - (cd scan/c/.git && $shell ../../../worktree-hook 2>../../../err) && + (cd scan/c/.git && $run ../../../worktree-hook 2>../../../err) && test_must_be_empty err && cached_requests worktree-slots >left && test_grep "|/a.git/0|" left && @@ -190,7 +211,7 @@ do test_expect_success "a push drops the pages of a repository whose url is escaped under $shell" ' fresh_slots && - (cd scan/foo+bar.git && $shell ../../cache-hook 2>../../err) && + (cd scan/foo+bar.git && $run ../../cache-hook 2>../../err) && test_must_be_empty err && cached_requests slots >left && test_grep "|/b.git/log/" left && @@ -203,7 +224,7 @@ do git -C scan/b.git config hooks.cgiturl b.git && sed "s|^scan_path=.*|scan_path=/nonexistent|" cache-hook >named-hook && grep -Fx "scan_path=/nonexistent" named-hook && - (cd scan/b.git && $shell ../../named-hook 2>../../err) && + (cd scan/b.git && $run ../../named-hook 2>../../err) && test_must_be_empty err && cached_requests slots >left && test_grep "|/a.git/log/" left && @@ -212,7 +233,7 @@ do test_expect_success "with no url to go on the whole cache goes under $shell" ' fresh_slots && - (cd scan/a.git && $shell ../../named-hook 2>../../err) && + (cd scan/a.git && $run ../../named-hook 2>../../err) && test_must_be_empty err && test "$(ls slots)" = 0123abcd.lock ' @@ -220,7 +241,7 @@ do test_expect_success "the cache hook does nothing without a cache root under $shell" ' sed "s|^cache_root=.*|cache_root='\''$PWD/none'\''|" cache-hook >rootless-hook && grep -Fx "cache_root='\''$PWD/none'\''" rootless-hook && - (cd scan/a.git && $shell ../../rootless-hook 2>../../err) && + (cd scan/a.git && $run ../../rootless-hook 2>../../err) && test_must_be_empty err && test_path_is_missing none ' @@ -229,7 +250,7 @@ do fresh_slots && test_when_finished "chmod 755 slots" && chmod 555 slots && - (cd scan/a.git && $shell ../../cache-hook 2>../../err) && + (cd scan/a.git && $run ../../cache-hook 2>../../err) && test_must_be_empty err && ls slots >left && test_cmp pristine-slots left @@ -269,7 +290,7 @@ for shell in $shells do test_expect_success "the age hook writes the newest branch commit date under $shell" ' rm -f plain.git/info/web/last-modified && - (cd plain.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd plain.git && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && test_cmp expect plain.git/info/web/last-modified && ls plain.git/info/web >entries && @@ -286,7 +307,7 @@ do cp kept plain.git/info/web/last-modified && test_when_finished "chmod 755 plain.git/info/web" && chmod 555 plain.git/info/web && - (cd plain.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd plain.git && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && test_cmp kept plain.git/info/web/last-modified && ls plain.git/info/web >entries && @@ -297,7 +318,7 @@ do rm -f plain.git/info/web/last-modified && cp kept plain.git/info/web/last-modified && chmod 444 plain.git/info/web/last-modified && - (cd plain.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd plain.git && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && test_cmp expect plain.git/info/web/last-modified ' @@ -307,7 +328,7 @@ do git -C work push -q ../tags-$shell.git release && mkdir -p tags-$shell.git/info/web && echo kept >tags-$shell.git/info/web/last-modified && - (cd tags-$shell.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd tags-$shell.git && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && test_cmp kept tags-$shell.git/info/web/last-modified ' @@ -317,7 +338,7 @@ do git -C work push -q ../closed-$shell.git main && test_when_finished "chmod 755 closed-$shell.git/info" && chmod 555 closed-$shell.git/info && - (cd closed-$shell.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd closed-$shell.git && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && test_path_is_missing closed-$shell.git/info/web ' @@ -327,7 +348,7 @@ do test_expect_success SANITY "the age hook keeps a shared directory group writable under $shell" ' git init -q --bare --shared=group shared-$shell.git && git -C work push -q ../shared-$shell.git main && - (cd shared-$shell.git && umask 022 && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd shared-$shell.git && umask 022 && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && ls -ld shared-$shell.git/info/web >mode && test_grep "^drwxrw[xs]" mode @@ -338,7 +359,7 @@ do test_expect_success "the age hook writes a file anyone can read under a tight umask under $shell" ' git init -q --bare private-$shell.git && git -C work push -q ../private-$shell.git main && - (cd private-$shell.git && umask 077 && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd private-$shell.git && umask 077 && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && ls -ld private-$shell.git/info/web private-$shell.git/info/web/last-modified >mode && test_grep "^drwxr-xr-x" mode && @@ -348,13 +369,13 @@ do test_expect_success "the age hook reads core.sharedRepository as git does under $shell" ' git -C private-$shell.git config core.sharedRepository FALSE && rm private-$shell.git/info/web/last-modified && - (cd private-$shell.git && umask 077 && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd private-$shell.git && umask 077 && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && ls -l private-$shell.git/info/web/last-modified >mode && test_grep "^-rw-r--r--" mode && git -C private-$shell.git config core.sharedRepository 0660 && rm private-$shell.git/info/web/last-modified && - (cd private-$shell.git && umask 077 && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + (cd private-$shell.git && umask 077 && $run "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && ls -l private-$shell.git/info/web/last-modified >mode && test_grep "^-rw-rw-r--" mode @@ -363,7 +384,7 @@ do test_expect_success "the commit-graph hook writes a graph with path filters under $shell" ' git init -q --bare graph-$shell.git && git -C work push -q ../graph-$shell.git main && - (cd graph-$shell.git && $shell "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && + (cd graph-$shell.git && $run "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && test_must_be_empty err && test_path_is_file graph-$shell.git/objects/info/commit-graphs/commit-graph-chain && grep -q BDAT graph-$shell.git/objects/info/commit-graphs/*.graph && @@ -373,7 +394,7 @@ do test_expect_success "the commit-graph hook writes a graph anyone can read under a tight umask under $shell" ' git init -q --bare private-graph-$shell.git && git -C work push -q ../private-graph-$shell.git main && - (cd private-graph-$shell.git && umask 077 && $shell "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && + (cd private-graph-$shell.git && umask 077 && $run "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && test_must_be_empty err && ls -l private-graph-$shell.git/objects/info/commit-graphs >modes && test_grep "commit-graph-chain" modes && @@ -388,7 +409,7 @@ do cp $graphs/commit-graph-chain chain-$shell && test_commit -C work graph-$shell && git -C work push -q ../graph-$shell.git HEAD:main && - (cd graph-$shell.git && $shell "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && + (cd graph-$shell.git && $run "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err) && test_must_be_empty err && newest=$(tail -n 1 $graphs/commit-graph-chain) && test -n "$newest" && |
