Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Add a helper for configs of several repositories
The configs a run of t0101 writes are byte for byte what they were. The
scan configs name no repository and descrc adds one to a copy of the
shared config, so those keep their own form.
| -rw-r--r-- | tests/setup.sh | 10 | |
| -rwxr-xr-x | tests/t0101-index.sh | 71 |
2 files changed, 32 insertions, 49 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index 26a3f67..ac6e293 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -293,6 +293,16 @@ cgitrc_repo() { "repo.url=$cgitrc_url$LF" "$cgitrc_path$LF" "$cgitrc_after" >"$cgitrc_file" } +# Writes a config to the file named first with the cache off and links rooted +# at /, as cgitrc_repo does, followed by the rest as lines of their own. They +# keep the order given, since a repo.* setting goes to the repository named +# last and a section takes in the repositories after it. +cgitrc_repos() { + cgitrc_file=$1 + shift + printf '%s\n' virtual-root=/ cache-size=0 "$@" >"$cgitrc_file" +} + # Writes the global settings named after the file ahead of a copy of the # shared cgitrc. The copy turns the cache off, because a page is cached under # its request alone and would otherwise come back as the shared config made diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index bf3de8c..e3d2148 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -78,14 +78,9 @@ test_expect_success 'a url matching no repository says so' ' ' test_expect_success 'a search finding nothing under a url prefix says so' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=a/x" && - echo "repo.path=$PWD/repos/foo/.git" && - echo "repo.url=a/y" && - echo "repo.path=$PWD/repos/foo/.git" - } >prefixrc && + cgitrc_repos prefixrc \ + repo.url=a/x "repo.path=$PWD/repos/foo/.git" \ + repo.url=a/y "repo.path=$PWD/repos/foo/.git" && cgit_ok prefixrc "url=a/" >tmp && test_grep ">a/x</a>" tmp && test_grep ">a/y</a>" tmp && @@ -117,22 +112,13 @@ test_expect_success 'set up repositories each column sorts apart' ' echo "2005-04-03 10:00:00 +0000" >orders/a.git/info/web/last-modified && echo "2005-04-05 10:00:00 +0000" >orders/b.git/info/web/last-modified && echo "2005-04-01 10:00:00 +0000" >orders/c.git/info/web/last-modified && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=c" && - echo "repo.path=$PWD/orders/c.git" && - echo "repo.desc=first by description" && - echo "repo.owner=second owner" && - echo "repo.url=a" && - echo "repo.path=$PWD/orders/a.git" && - echo "repo.desc=third by description" && - echo "repo.owner=first owner" && - echo "repo.url=b" && - echo "repo.path=$PWD/orders/b.git" && - echo "repo.desc=second by description" && - echo "repo.owner=third owner" - } >orderrc && + cgitrc_repos orderrc \ + repo.url=c "repo.path=$PWD/orders/c.git" \ + "repo.desc=first by description" "repo.owner=second owner" \ + repo.url=a "repo.path=$PWD/orders/a.git" \ + "repo.desc=third by description" "repo.owner=first owner" \ + repo.url=b "repo.path=$PWD/orders/b.git" \ + "repo.desc=second by description" "repo.owner=third owner" && test_index_order "url=" c a b ' @@ -172,20 +158,13 @@ test_expect_success 'set up repositories in two sections' ' echo "2005-04-01 10:00:00 +0000" >sections/a2.git/info/web/last-modified && echo "2005-04-05 10:00:00 +0000" >sections/a3.git/info/web/last-modified && echo "2005-04-03 10:00:00 +0000" >sections/a1.git/info/web/last-modified && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-index-links=1" && - echo "section=zeta" && - echo "repo.url=z1" && - echo "repo.path=$PWD/sections/z1.git" && - echo "section=alpha" && - for name in a2 a3 a1 - do - echo "repo.url=$name" && - echo "repo.path=$PWD/sections/$name.git" || return 1 - done - } >sectionrc && + cgitrc_repos sectionrc enable-index-links=1 \ + section=zeta \ + repo.url=z1 "repo.path=$PWD/sections/z1.git" \ + section=alpha \ + repo.url=a2 "repo.path=$PWD/sections/a2.git" \ + repo.url=a3 "repo.path=$PWD/sections/a3.git" \ + repo.url=a1 "repo.path=$PWD/sections/a1.git" && { echo "section-sort=1" && cat sectionrc @@ -260,17 +239,11 @@ test_expect_success 'a scan lists repositories in path order' ' test_expect_success 'a repository without repo.desc reads its description file' ' mkrepo repos/described 1 && printf "told by the file\nsecond line\n" >repos/described/.git/description && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=described" && - echo "repo.path=$PWD/repos/described/.git" && - echo "repo.url=overridden" && - echo "repo.path=$PWD/repos/described/.git" && - echo "repo.desc=from cgitrc" && - echo "repo.url=placeholder" && - echo "repo.path=$PWD/repos/foo/.git" - } >describedrc && + cgitrc_repos describedrc \ + repo.url=described "repo.path=$PWD/repos/described/.git" \ + repo.url=overridden "repo.path=$PWD/repos/described/.git" \ + "repo.desc=from cgitrc" \ + repo.url=placeholder "repo.path=$PWD/repos/foo/.git" && cgit_ok describedrc "url=" >tmp && grep "href=./described/.>told by the file</a>" tmp && grep "href=./overridden/.>from cgitrc</a>" tmp && |
