Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0104-tree.sh | 86 |
1 file changed, 50 insertions, 36 deletions
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 "<th class=.ls-links. scope=.col. aria-label=.Links.></th>" 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 "<a id=.n1. href=.#n1.>1</a>" tmp ' -test_expect_success 'no line 2' ' - ! grep "<a id=.n2. href=.#n2.>2</a>" tmp +test_expect_success 'a one line file gets no second line number' ' + cgit_ok_url "bar/tree/file-50" >tmp && + test_grep "<a id=.n1. href=.#n1.>1</a>" tmp && + test_grep ! "<a id=.n2. href=.#n2.>2</a>" 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 "<code>a<span class=.escape.>\\\\r</span>b<span class=.escape.>\\\\v</span>c" tmp && grep "c<span class=.escape.>\\\\f</span>d<span class=.escape.>\\\\u0085</span>e" tmp && grep "e<span class=.escape.>\\\\u2028</span>f<span class=.escape.>\\\\u2029</span>g$" 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 "<a id=.n3. href=.#n3.>3</a>" tmp && - ! grep "<a id=.n4. href=.#n4.>4</a>" tmp + cgit_ok breaksrc "url=breaks/tree/breaks.txt" >tmp && + test_grep "<a id=.n3. href=.#n3.>3</a>" tmp && + test_grep ! "<a id=.n4. href=.#n4.>4</a>" 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 "<code>a<span class=.escape.>\\\\r</span>b<span class=.escape.>\\\\v</span>c" tmp && + grep "c<span class=.escape.>\\\\f</span>d<span class=.escape.>\\\\u0085</span>e" tmp && grep "e<span class=.escape.>\\\\u2028</span>f<span class=.escape.>\\\\u2029</span>g$" tmp && grep "^i<span class=.escape.>\\\\r</span></code>" 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\\}</pre></div>" 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: <a href=./nested/tree/.>root</a>/<a href=./nested/tree/a.>a</a>/<a href=./nested/tree/a/b.>b</a>/<a href=./nested/blame/a/b/file.txt.>file.txt</a>" 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.>^</a>" 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</span>" tmp && - ! grep ">vendor/sub</span>" tmp + test_grep ! ">vendor/sub</span>" 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.>-</td>" row + test_grep "class=.ls-size.>-</td>" row ' test_expect_success 'a submodule row offers log but not blame or plain' ' - grep ">log</a>" row && - ! grep ">blame</a>" row && - ! grep ">plain</a>" row + cgit_ok submodrc "url=submodules/tree/vendor" >tmp && + grep "ls-mod" tmp >row && + test_grep ">log</a>" row && + test_grep ! ">blame</a>" row && + test_grep ! ">plain</a>" 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</a>" 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 " -> <a class=.ls-blob. href=./links/tree/target.txt.>target.txt</a>" tmp && grep " -> /etc/passwd</td>" 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</a>" tmp && - ! grep "href=./links/blame/rel.>blame</a>" tmp && - cgit_rc linksblamerc "url=links/tree/rel" >tmp && + test_grep ! "href=./links/blame/rel.>blame</a>" tmp && + cgit_ok linksblamerc "url=links/tree/rel" >tmp && grep "<div class=.blob-header.>" tmp && - ! grep ">blame</a>" tmp + test_grep ! ">blame</a>" 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</a></td>" tmp && - ! grep " / </td>" tmp + test_grep ! " / </td>" 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</a></td>" tmp && - grep "href=./cut/log/a?h=odd.>log</a>" tmp + grep "href=./cut/log/a?h=odd.>log</a>" tmp && + test_grep "</html>" 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 "<table class=.bin-blob. tabindex=.0. aria-label=.Hex dump.>" tmp && grep "<td class=.right.>0000</td><td class=.hex.> 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 "<td class=.right.>ffe0</td>" tmp && - ! grep "<td class=.right.>10000</td>" tmp && + test_grep ! "<td class=.right.>10000</td>" tmp && grep "<div class=.truncated.>Only the first 64 KB of this file are shown. <a href=./bin/plain/big.bin.>View the whole file</a>.</div>" tmp ' |
