Diff options
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0104-tree.sh | 76 |
1 file changed, 35 insertions, 41 deletions
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 41134a4..26a0cb4 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -9,7 +9,7 @@ test_description='Check content on tree page' . ./setup.sh test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp' -test_expect_success 'find file-1' 'grep "file-1" tmp' +test_expect_success 'find file-1' 'grep ">file-1<" 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 @@ -44,17 +44,11 @@ test_expect_success 'set up a file holding the characters a browser breaks at' ' git add breaks.txt && git commit -m breaks ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-blame=1" && - echo "repo.url=breaks" && - echo "repo.path=$PWD/repos/breaks/.git" - } >breaksrc + cgitrc_repo breaksrc breaks enable-blame=1 ' test_expect_success 'each of them is shown as an escape in the tree' ' - CGIT_CONFIG="$PWD/breaksrc" QUERY_STRING="url=breaks/tree/breaks.txt" cgit >tmp && + cgit_rc 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 @@ -73,7 +67,7 @@ test_expect_success 'the numbers count only the lines git counts' ' ' test_expect_success 'the blame page escapes them the same way' ' - CGIT_CONFIG="$PWD/breaksrc" QUERY_STRING="url=breaks/blame/breaks.txt" cgit >tmp && + cgit_rc breaksrc "url=breaks/blame/breaks.txt" >tmp && grep "<code>a<span class=.escape.>\\\\r</span>b<span class=.escape.>\\\\v</span>c" 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 @@ -105,17 +99,11 @@ test_expect_success 'set up a repo with a nested submodule' ' git update-index --add --cacheinfo 160000,$sub,vendor/sub && git commit -m gitlink ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-blame=1" && - echo "repo.url=submodules" && - echo "repo.path=$PWD/repos/submodules/.git" - } >submodrc + cgitrc_repo submodrc submodules enable-blame=1 ' test_expect_success 'generate submodules/tree/vendor' ' - CGIT_CONFIG="$PWD/submodrc" QUERY_STRING="url=submodules/tree/vendor" cgit >tmp + cgit_rc submodrc "url=submodules/tree/vendor" >tmp ' test_expect_success 'a submodule row shows the entry name alone' ' @@ -134,14 +122,13 @@ test_expect_success 'a submodule row shows no size' ' ' test_expect_success 'a submodule row offers log but not blame or plain' ' - grep "ls-mod" tmp >row && grep ">log</a>" row && ! grep ">blame</a>" row && ! grep ">plain</a>" row ' test_expect_success 'a file row still offers blame' ' - CGIT_CONFIG="$PWD/submodrc" QUERY_STRING="url=submodules/tree/" cgit >tmp && + cgit_rc submodrc "url=submodules/tree/" >tmp && grep ">blame</a>" tmp ' @@ -159,13 +146,8 @@ test_expect_success 'only a link target inside the tree is linked' ' git update-index --add --cacheinfo 120000,$abs,abs && git commit -m links ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=links" && - echo "repo.path=$PWD/repos/links/.git" - } >linksrc && - CGIT_CONFIG="$PWD/linksrc" QUERY_STRING="url=links/tree/" cgit >tmp && + cgitrc_repo linksrc links && + cgit_rc 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 @@ -187,17 +169,34 @@ test_expect_success 'a long directory chain ends on a link' ' git add . && git commit -m deep ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=deep" && - echo "repo.path=$PWD/repos/deep/.git" - } >deeprc && - CGIT_CONFIG="$PWD/deeprc" QUERY_STRING="url=deep/tree/" cgit >tmp && + cgitrc_repo deeprc deep && + cgit_rc deeprc "url=deep/tree/" >tmp && grep ">d15</a></td>" tmp && ! grep " / </td>" tmp ' +# Git holds one object per id, as the type it was first looked up as, so a +# folder the commit also names as its parent cannot be read as a tree and the +# chain stops on it. The rest of the row still belongs to the first folder. +test_expect_success 'a broken chain keeps the row links on the first folder' ' + test_create_repo repos/cut && + ( + cd repos/cut && + mkdir -p a/b && + echo x >a/b/file && + git add a && + git commit -m base && + odd=$(printf "tree %s\\nparent %s\\nauthor A <a@x> 1700000000 +0000\\ncommitter A <a@x> 1700000000 +0000\\n\\nodd\\n" \ + $(git rev-parse HEAD^{tree}) $(git rev-parse HEAD:a/b) | + git hash-object -t commit -w --stdin --literally) && + git update-ref refs/heads/odd $odd + ) && + cgitrc_repo cutrc cut && + cgit_rc cutrc "url=cut/tree/&h=odd" >tmp && + grep ">b</a></td>" tmp && + grep "href=./cut/log/a?h=odd.>log</a>" tmp +' + test_expect_success 'a binary file in the tree shows as a hex dump' ' test_create_repo repos/bin && ( @@ -206,13 +205,8 @@ test_expect_success 'a binary file in the tree shows as a hex dump' ' git add blob.bin && git commit -m binary ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=bin" && - echo "repo.path=$PWD/repos/bin/.git" - } >binrc && - CGIT_CONFIG="$PWD/binrc" QUERY_STRING="url=bin/tree/blob.bin" cgit >tmp && + cgitrc_repo binrc bin && + cgit_rc binrc "url=bin/tree/blob.bin" >tmp && grep "<table class=.bin-blob.>" tmp && grep "<td class=.right.>0000</td><td class=.hex.> 00 01 02 62 69 6e" tmp ' |
