Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Add the shared config writers and cgit_rc
The helpers are named by kind. cgitrc_repo and cgitrc_copy write the
config file named first, and cgit_url, cgit_query and cgit_rc run cgit,
each named after what it is handed first. A repository copies its
defaults from the globals read before its repo.url, so cgitrc_repo
places every setting itself, and a global can no longer land where it
silently stops applying. The t00xx and t01xx files move to them here.
Diffstat (limited to 'tests/t0104-tree.sh')
| -rwxr-xr-x | tests/t0104-tree.sh | 60 |
1 file changed, 14 insertions, 46 deletions
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index e6985f9..26a0cb4 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -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' ' @@ -140,7 +128,7 @@ test_expect_success 'a submodule row offers log but not blame or plain' ' ' 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 ' @@ -158,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 @@ -186,13 +169,8 @@ 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 ' @@ -213,13 +191,8 @@ test_expect_success 'a broken chain keeps the row links on the first folder' ' git hash-object -t commit -w --stdin --literally) && git update-ref refs/heads/odd $odd ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=cut" && - echo "repo.path=$PWD/repos/cut/.git" - } >cutrc && - CGIT_CONFIG="$PWD/cutrc" QUERY_STRING="url=cut/tree/&h=odd" cgit >tmp && + 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 ' @@ -232,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 ' |
