Diff options
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0109-patch.sh | 62 |
1 file changed, 18 insertions, 44 deletions
diff --git a/tests/t0109-patch.sh b/tests/t0109-patch.sh index 6840f0c..bc942fe 100755 --- a/tests/t0109-patch.sh +++ b/tests/t0109-patch.sh @@ -2,8 +2,7 @@ # The patch page serves mail ready patches, compared line for line against # git format-patch for a single commit and for a range, once the CGI headers -# are stripped. The last check sets max-patch-count so a range wider than -# the limit comes back cut short. +# are stripped. test_description='Check content on patch page' . ./setup.sh @@ -19,38 +18,22 @@ check_cgit_signature() { } test_expect_success 'generate foo/patch' ' - cgit_query "url=foo/patch" >tmp -' - -test_expect_success 'find `From:` line' ' - grep "^From: " tmp -' - -test_expect_success 'find `Date:` line' ' - grep "^Date: " tmp -' - -test_expect_success 'find `Subject:` line' ' - grep "^Subject: commit 5" tmp -' - -test_expect_success 'find `cgit` signature' ' - check_cgit_signature + cgit_url "foo/patch" >tmp ' test_expect_success 'compare with output of git-format-patch(1)' ' - git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \ - --signature="cgit" --stdout HEAD^ >tmp2 && - strip_headers <tmp >tmp_ && - test_cmp tmp_ tmp2 + git -C repos/foo format-patch --subject-prefix="" \ + --signature="cgit" --stdout HEAD^ >expect && + strip_headers <tmp >actual && + test_cmp expect actual ' test_expect_success 'find initial commit' ' - root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD) + root=$(git -C repos/foo rev-list --max-parents=0 HEAD) ' test_expect_success 'generate patch for initial commit' ' - cgit_query "url=foo/patch&id=$root" >tmp + cgit_url "foo/patch&id=$root" >tmp ' test_expect_success 'find `cgit` signature on the initial commit' ' @@ -58,20 +41,16 @@ test_expect_success 'find `cgit` signature on the initial commit' ' ' test_expect_success 'generate patches for multiple commits' ' - id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) && - id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) && - cgit_query "url=foo/patch&id=$id&id2=$id2" >tmp -' - -test_expect_success 'find `cgit` signature on the range' ' - check_cgit_signature + id=$(git -C repos/foo rev-parse HEAD) && + id2=$(git -C repos/foo rev-parse HEAD~3) && + cgit_url "foo/patch&id=$id&id2=$id2" >tmp ' test_expect_success 'compare the range with git-format-patch(1)' ' - git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \ - -N --signature="cgit" --stdout HEAD~3..HEAD >tmp2 && - strip_headers <tmp >tmp_ && - test_cmp tmp_ tmp2 + git -C repos/foo format-patch --subject-prefix="" \ + -N --signature="cgit" --stdout HEAD~3..HEAD >expect && + strip_headers <tmp >actual && + test_cmp expect actual ' test_expect_success 'max-patch-count bounds a patch range' ' @@ -81,18 +60,13 @@ test_expect_success 'max-patch-count bounds a patch range' ' echo "repo.url=foo" && echo "repo.path=$PWD/repos/foo/.git" } >patchcountrc && - id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) && - root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD) && - CGIT_CONFIG="$PWD/patchcountrc" QUERY_STRING="url=foo/patch&id=$id&id2=$root" cgit >tmp && + cgit_rc patchcountrc "url=foo/patch&id=$id&id2=$root" >tmp && test $(grep -c "^From " tmp) -eq 2 ' test_expect_success 'the signature names the version when asked to' ' - { - echo "enable-version-info=1" && - sed "s/^cache-size=.*/cache-size=0/" cgitrc - } >versionrc && - CGIT_CONFIG="$PWD/versionrc" QUERY_STRING="url=foo/patch" cgit >tmp && + cgitrc_copy versionrc enable-version-info=1 && + cgit_rc versionrc "url=foo/patch" >tmp && check_cgit_signature "$CGIT_VERSION" ' |
