From 6e9ae82a6d97f87a4de2ed64b383ee5b1c1b8ebf Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 12:11:06 -1000 Subject: Hold the tree tests to a working page The tree requests passed on any answer short of a crash. Several tests read a page or a row an earlier test wrote, so run alone they passed or failed by accident, and two leant on a repository from the test before without saying so. The file-50 check also matched its href, and the blame check skipped the form feed and NEL its title covers. --- tests/t0104-tree.sh | 86 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 36 deletions(-) (limited to 'tests/t0104-tree.sh') diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 5fdc6ac..2a7c741 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -8,21 +8,23 @@ test_description='Check content on tree page' . ./setup.sh -test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp' +test_expect_success 'generate bar/tree' 'cgit_ok_url "bar/tree" >tmp' test_expect_success 'find file-1' 'grep ">file-1<" tmp' -test_expect_success 'find file-50' 'grep "file-50" tmp' +test_expect_success 'find file-50' 'grep ">file-50<" tmp' test_expect_success 'the links column has a name' ' grep "" tmp ' -test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >tmp' +test_expect_success 'generate bar/tree/file-50' 'cgit_ok_url "bar/tree/file-50" >tmp' test_expect_success 'find line 1' ' grep "1" tmp ' -test_expect_success 'no line 2' ' - ! grep "2" tmp +test_expect_success 'a one line file gets no second line number' ' + cgit_ok_url "bar/tree/file-50" >tmp && + test_grep "1" tmp && + test_grep ! "2" tmp ' # The table only sets the numbers beside the code, so a screen reader is told @@ -54,13 +56,14 @@ test_expect_success 'set up a file holding the characters a browser breaks at' ' ' test_expect_success 'each of them is shown as an escape in the tree' ' - cgit_rc breaksrc "url=breaks/tree/breaks.txt" >tmp && + cgit_ok breaksrc "url=breaks/tree/breaks.txt" >tmp && grep "a\\\\rb\\\\vc" tmp && grep "c\\\\fd\\\\u0085e" tmp && grep "e\\\\u2028f\\\\u2029g$" tmp ' test_expect_success 'only a carriage return before a line feed is left as it is' ' + cgit_ok breaksrc "url=breaks/tree/breaks.txt" >tmp && printf "h\\r\\n" >expect && grep "^h" tmp >actual && test_cmp expect actual && @@ -68,13 +71,15 @@ test_expect_success 'only a carriage return before a line feed is left as it is' ' test_expect_success 'the numbers count only the lines git counts' ' - grep "3" tmp && - ! grep "4" tmp + cgit_ok breaksrc "url=breaks/tree/breaks.txt" >tmp && + test_grep "3" tmp && + test_grep ! "4" tmp ' test_expect_success 'the blame page escapes them the same way' ' - cgit_rc breaksrc "url=breaks/blame/breaks.txt" >tmp && + cgit_ok breaksrc "url=breaks/blame/breaks.txt" >tmp && grep "a\\\\rb\\\\vc" tmp && + grep "c\\\\fd\\\\u0085e" tmp && grep "e\\\\u2028f\\\\u2029g$" tmp && grep "^i\\\\r" tmp ' @@ -82,6 +87,7 @@ test_expect_success 'the blame page escapes them the same way' ' # The striped background is padded with spaces to the widest line, which is # 31 columns once its six escapes are written out, though it is 18 bytes. test_expect_success 'the blame stripes are as wide as the escaped line' ' + cgit_ok breaksrc "url=breaks/blame/breaks.txt" >tmp && grep "^ \\{31\\}" tmp ' @@ -97,7 +103,7 @@ test_expect_success 'the folder crumbs of a blame page lead to the tree' ' git commit -m nested ) && cgitrc_repo nestedrc nested enable-blame=1 && - cgit_rc nestedrc "url=nested/blame/a/b/file.txt" >tmp && + cgit_ok nestedrc "url=nested/blame/a/b/file.txt" >tmp && grep "path: root/a/b/file.txt" tmp ' @@ -116,19 +122,19 @@ test_expect_success 'blame links a commit to the file before it' ' git commit -am "rename a.txt" ) && cgitrc_repo renamedrc renamed enable-blame=1 && - cgit_rc renamedrc "url=renamed/blame/b.txt" >tmp && + cgit_ok renamedrc "url=renamed/blame/b.txt" >tmp && added=$(git -C repos/renamed rev-parse HEAD~1) && grep "title=.Blame the previous revision. href=./renamed/blame/a.txt?id=$added.>^" tmp && test $(grep -c "Blame the previous revision" tmp) = 1 ' -test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp' +test_expect_success 'generate foo+bar/tree' 'cgit_ok_url "foo%2bbar/tree" >tmp' test_expect_success 'verify a+b link' ' grep "/foo%2Bbar/tree/a%2Bb" tmp ' -test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >tmp' +test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_ok_url "foo%2bbar/tree&h=1%2b2" >tmp' test_expect_success 'verify a+b?h=1+2 link' ' grep "/foo%2Bbar/tree/a%2Bb?h=1%2B2" tmp @@ -146,12 +152,12 @@ test_expect_success 'set up a repo with a nested submodule' ' ' test_expect_success 'generate submodules/tree/vendor' ' - cgit_rc submodrc "url=submodules/tree/vendor" >tmp + cgit_ok submodrc "url=submodules/tree/vendor" >tmp ' test_expect_success 'a submodule row shows the entry name alone' ' grep "class=.ls-mod.>sub" tmp && - ! grep ">vendor/sub" tmp + test_grep ! ">vendor/sub" tmp ' test_expect_success 'the submodule hash is titled with the full id' ' @@ -160,18 +166,21 @@ test_expect_success 'the submodule hash is titled with the full id' ' ' test_expect_success 'a submodule row shows no size' ' + cgit_ok submodrc "url=submodules/tree/vendor" >tmp && grep "ls-mod" tmp >row && - grep "class=.ls-size.>-" row + test_grep "class=.ls-size.>-" row ' test_expect_success 'a submodule row offers log but not blame or plain' ' - grep ">log" row && - ! grep ">blame" row && - ! grep ">plain" row + cgit_ok submodrc "url=submodules/tree/vendor" >tmp && + grep "ls-mod" tmp >row && + test_grep ">log" row && + test_grep ! ">blame" row && + test_grep ! ">plain" row ' test_expect_success 'a file row still offers blame' ' - cgit_rc submodrc "url=submodules/tree/" >tmp && + cgit_ok submodrc "url=submodules/tree/" >tmp && grep ">blame" tmp ' @@ -199,21 +208,22 @@ test_expect_success 'only a link target inside the tree is linked' ' git commit -m links ) && cgitrc_repo linksrc links && - cgit_rc linksrc "url=links/tree/" >tmp && + cgit_ok linksrc "url=links/tree/" >tmp && grep " -> target.txt" tmp && grep " -> /etc/passwd" tmp && - ! grep "href=./links/tree/etc/passwd" tmp + test_grep ! "href=./links/tree/etc/passwd" tmp ' -# Blame takes a regular file alone, so a symlink is not offered it. +# Blame takes a regular file alone, so a symlink is not offered it. The +# links repository is the one the test above built. test_expect_success 'a symlink is not offered blame' ' cgitrc_repo linksblamerc links enable-blame=1 && - cgit_rc linksblamerc "url=links/tree/" >tmp && + cgit_ok linksblamerc "url=links/tree/" >tmp && grep "href=./links/blame/target.txt.>blame" tmp && - ! grep "href=./links/blame/rel.>blame" tmp && - cgit_rc linksblamerc "url=links/tree/rel" >tmp && + test_grep ! "href=./links/blame/rel.>blame" tmp && + cgit_ok linksblamerc "url=links/tree/rel" >tmp && grep "
" tmp && - ! grep ">blame" tmp + test_grep ! ">blame" tmp ' # A row follows a chain of single directories for a set number of levels and @@ -233,9 +243,9 @@ test_expect_success 'a long directory chain ends on a link' ' git commit -m deep ) && cgitrc_repo deeprc deep && - cgit_rc deeprc "url=deep/tree/" >tmp && + cgit_ok deeprc "url=deep/tree/" >tmp && grep ">d15" tmp && - ! grep " / " tmp + test_grep ! " / " tmp ' # Git holds one object per id, as the type it was first looked up as, so a @@ -255,9 +265,12 @@ test_expect_success 'a broken chain keeps the row links on the first folder' ' git update-ref refs/heads/odd $odd ) && cgitrc_repo cutrc cut && - cgit_rc cutrc "url=cut/tree/&h=odd" >tmp && + cgit_rc cutrc "url=cut/tree/&h=odd" >tmp 2>err && + test_grep "^Status: 200" tmp && + test_grep "object $(git -C repos/cut rev-parse HEAD:a/b) is a commit, not a tree" err && grep ">b" tmp && - grep "href=./cut/log/a?h=odd.>log" tmp + grep "href=./cut/log/a?h=odd.>log" tmp && + test_grep "" tmp ' test_expect_success 'a binary file in the tree shows as a hex dump' ' @@ -269,10 +282,10 @@ test_expect_success 'a binary file in the tree shows as a hex dump' ' git commit -m binary ) && cgitrc_repo binrc bin && - cgit_rc binrc "url=bin/tree/blob.bin" >tmp && + cgit_ok binrc "url=bin/tree/blob.bin" >tmp && grep "" tmp && grep "" tmp && - ! grep "" tmp && + test_grep ! "" tmp && grep "
Only the first 64 KB of this file are shown. View the whole file.
" tmp ' -- cgit 2.12.1
0000 00 01 02 62 69 6e" tmp && - ! grep "class=.truncated." tmp + test_grep ! "class=.truncated." tmp ' # The dump scrolls sideways inside its own table, which a keyboard reaches @@ -285,7 +298,8 @@ test_expect_success 'a focused hex dump shows the focus ring' ' ' # Each byte of the dump costs several bytes of markup, so a large binary is -# dumped up to its first 64 KB and links to the whole file. +# dumped up to its first 64 KB and links to the whole file. It joins the bin +# repository the test above built. test_expect_success 'a large binary is dumped only in part' ' ( cd repos/bin && @@ -294,9 +308,9 @@ test_expect_success 'a large binary is dumped only in part' ' git add big.bin && git commit -m "large binary" ) && - cgit_rc binrc "url=bin/tree/big.bin" >tmp && + cgit_ok binrc "url=bin/tree/big.bin" >tmp && grep "ffe01000010000