Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check the rawdiff is served as plain text
strip_headers dropped the headers before every compare, so a rawdiff
served under another type passed. Each test now makes its own request,
and the ids it needs, rather than reading what an earlier one left.
Diffstat (limited to 'tests/t0108-rawdiff.sh')
| -rwxr-xr-x | tests/t0108-rawdiff.sh | 41 |
1 file changed, 17 insertions, 24 deletions
diff --git a/tests/t0108-rawdiff.sh b/tests/t0108-rawdiff.sh index 66f0cbe..afd1ff1 100755 --- a/tests/t0108-rawdiff.sh +++ b/tests/t0108-rawdiff.sh @@ -2,54 +2,47 @@ # The rawdiff page serves a diff as plain text fit for patch. Every test # runs the git command the page mirrors and compares the two byte for byte, -# over an ordinary commit, the parentless initial commit and a range. +# over an ordinary commit, the parentless initial commit, a range, a path and +# a rename. test_description='Check content on rawdiff page' . ./setup.sh -test_expect_success 'generate foo/rawdiff' ' - cgit_url "foo/rawdiff" >tmp -' - -test_expect_success 'compare with output of git-diff(1)' ' +test_expect_success 'a commit is served as text matching git diff' ' + cgit_ok_url "foo/rawdiff" >tmp && + sed "/^$/q" tmp | grep "^Content-Type: text/plain" && git -C repos/foo diff HEAD^.. >expect && strip_headers <tmp >actual && test_cmp expect actual ' -test_expect_success 'find initial commit' ' - root=$(git -C repos/foo rev-list --max-parents=0 HEAD) -' - -test_expect_success 'generate diff for initial commit' ' - cgit_url "foo/rawdiff&id=$root" >tmp -' - -test_expect_success 'compare with output of git-diff-tree(1)' ' +test_expect_success 'the initial commit matches git diff-tree' ' + root=$(git -C repos/foo rev-list --max-parents=0 HEAD) && + cgit_ok_url "foo/rawdiff&id=$root" >tmp && git -C repos/foo diff-tree -p --no-commit-id --root "$root" >expect && strip_headers <tmp >actual && test_cmp expect actual ' -test_expect_success 'generate diff for multiple commits' ' +test_expect_success 'a range matches git diff over the same range' ' id=$(git -C repos/foo rev-parse HEAD) && id2=$(git -C repos/foo rev-parse HEAD~3) && - cgit_url "foo/rawdiff&id=$id&id2=$id2" >tmp -' - -test_expect_success 'compare with output of git-diff(1)' ' + cgit_ok_url "foo/rawdiff&id=$id&id2=$id2" >tmp && git -C repos/foo diff HEAD~3..HEAD >expect && strip_headers <tmp >actual && test_cmp expect actual ' +# The grep keeps an empty expect, which an empty page would match, from +# passing. test_expect_success 'a path limits the diff to that file' ' - cgit_url "foo/rawdiff/file-4&id=$id&id2=$id2" >tmp && + id=$(git -C repos/foo rev-parse HEAD) && + id2=$(git -C repos/foo rev-parse HEAD~3) && + cgit_ok_url "foo/rawdiff/file-4&id=$id&id2=$id2" >tmp && git -C repos/foo diff HEAD~3..HEAD -- file-4 >expect && strip_headers <tmp >actual && test_cmp expect actual && - grep "file-4" actual && - ! grep "file-5" actual + grep "file-4" actual ' # The old name of a file renamed in the change joins the limit, so the diff @@ -66,7 +59,7 @@ test_expect_success 'a renamed file is diffed as the rename' ' git commit -am "rename old.txt" ) && cgitrc_repo movedrc moved && - cgit_rc movedrc "url=moved/rawdiff/new.txt" >tmp && + cgit_ok movedrc "url=moved/rawdiff/new.txt" >tmp && git -C repos/moved diff HEAD^ HEAD -- old.txt new.txt >expect && strip_headers <tmp >actual && test_cmp expect actual && |
