From a3bb7c69c0295cb2fc7909559456e798b222fccd Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:56:59 -0700 Subject: 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. --- tests/t0005-markup.sh | 74 +++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 43 deletions(-) (limited to 'tests/t0005-markup.sh') diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index 60a9990..a6dd028 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -17,23 +17,13 @@ test_expect_success 'set up a repository with a file that has an extension' ' git add dir && git commit -m sources ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-blame=1" && - echo "max-stats=year" && - echo "readme=:file-1" && - echo "repo.url=hooks" && - echo "repo.path=$PWD/repos/hooks/.git" - } >hooksrc + cgitrc_repo hooksrc hooks enable-blame=1 max-stats=year readme=:file-1 ' -hooks() { CGIT_CONFIG="$PWD/hooksrc" QUERY_STRING="url=$1" cgit; } - test_expect_success 'the root names the page and the repository' ' - hooks "" >tmp && + cgit_rc hooksrc "url=" >tmp && grep "
" tmp && - hooks "hooks/log/" >tmp && + cgit_rc hooksrc "url=hooks/log/" >tmp && grep "
" tmp ' @@ -46,14 +36,14 @@ test_expect_success 'the landmarks and the search form are in place' ' ' test_expect_success 'the pages name the versions only when asked to' ' - hooks "hooks/" >footer && + cgit_rc hooksrc "url=hooks/" >footer && grep "" footer && grep "" footer && { echo "enable-version-info=1" && cat hooksrc } >versionrc && - CGIT_CONFIG="$PWD/versionrc" QUERY_STRING="url=hooks/" cgit >footer && + cgit_rc versionrc "url=hooks/" >footer && grep "]*>" footer && grep "" footer && echo "
our own
" >footer.html && @@ -62,7 +52,7 @@ test_expect_success 'the pages name the versions only when asked to' ' echo "footer=$PWD/footer.html" && cat hooksrc } >versionrc && - CGIT_CONFIG="$PWD/versionrc" QUERY_STRING="url=hooks/" cgit >footer && + cgit_rc versionrc "url=hooks/" >footer && grep "
our own
" footer && ! grep "git-scm" footer ' @@ -73,58 +63,58 @@ test_expect_success 'the listings name themselves, their sections and their rows grep "" tmp && grep "class=.active. aria-current=.page." tmp && grep "" tmp && - hooks "" >tmp && + cgit_rc hooksrc "url=" >tmp && grep "" tmp && grep "" tmp && grep "" tmp && - hooks "hooks/" >tmp && + cgit_rc hooksrc "url=hooks/" >tmp && grep "
" tmp && grep "" tmp && grep "" tmp && - hooks "hooks/tree/" >tmp && + cgit_rc hooksrc "url=hooks/tree/" >tmp && grep "
" tmp && grep "" tmp && grep "" tmp && - hooks "hooks/tree/dir/" >tmp && + cgit_rc hooksrc "url=hooks/tree/dir/" >tmp && grep "class=.ls-blob ext-c." tmp ' test_expect_success 'the diff pages wrap each file and label their controls' ' - hooks "hooks/commit/" >tmp && + cgit_rc hooksrc "url=hooks/commit/" >tmp && grep "
" tmp && grep "" tmp && grep "
" tmp && grep "" tmp && grep "
" tmp && - hooks "hooks/stats/" >tmp && + cgit_rc hooksrc "url=hooks/stats/" >tmp && grep "" tmp ' test_expect_success 'the blob, blame and about pages open with their own containers' ' - hooks "hooks/tree/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/tree/dir/hello.c" >tmp && grep "
" tmp && grep "tmp && + cgit_rc hooksrc "url=hooks/blame/dir/hello.c" >tmp && grep "
" tmp && - hooks "hooks/about/" >tmp && + cgit_rc hooksrc "url=hooks/about/" >tmp && grep "
" tmp ' test_expect_success 'each page names itself, then the repository and the site' ' site="Git repository browser" && - hooks "hooks/" >tmp && + cgit_rc hooksrc "url=hooks/" >tmp && grep "hooks - $site" tmp && for page in about log refs tree stats do - hooks "hooks/$page/" >tmp && + cgit_rc hooksrc "url=hooks/$page/" >tmp && grep "$page - hooks - $site" tmp || return 1 done && - hooks "hooks/tree/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/tree/dir/hello.c" >tmp && grep "hello.c < dir - hooks - $site" tmp && - hooks "hooks/blame/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/blame/dir/hello.c" >tmp && grep "blame - hello.c < dir - hooks - $site" tmp ' @@ -151,7 +141,7 @@ test_expect_success 'the page background is the same everywhere it is set' ' test_line_count = 1 expect && sed -n "/^html.cgit-standalone {\$/,/^}/s/^ background: light-dark(\(#[0-9a-f]*\), \(#[0-9a-f]*\));\$/\1 \2/p" "$css" >actual && test_cmp expect actual && - hooks "hooks/" >tmp && + cgit_rc hooksrc "url=hooks/" >tmp && light=$(sed -n "s/.*theme-color. media=.(prefers-color-scheme: light). content=.\(#[0-9a-f]*\).*/\1/p" tmp) && dark=$(sed -n "s/.*theme-color. media=.(prefers-color-scheme: dark). content=.\(#[0-9a-f]*\).*/\1/p" tmp) && echo "$light $dark" >actual && @@ -159,7 +149,7 @@ test_expect_success 'the page background is the same everywhere it is set' ' ' test_expect_success 'the script waits for the page instead of holding it up' ' - hooks "hooks/" >tmp && + cgit_rc hooksrc "url=hooks/" >tmp && grep "" tmp ' @@ -205,31 +195,29 @@ test_expect_success 'set up the remaining kinds of entry' ' } >morerc ' -more() { CGIT_CONFIG="$PWD/morerc" QUERY_STRING="url=$1" cgit; } - test_expect_success 'the refs, summary and tree name every section and row' ' - more "hooks/refs/" >tmp && + cgit_rc morerc "url=hooks/refs/" >tmp && grep "
author
" tmp && grep "" tmp && grep "" tmp && - more "hooks/" >tmp && + cgit_rc morerc "url=hooks/" >tmp && grep "" tmp && - more "hooks/tree/" >tmp && + cgit_rc morerc "url=hooks/tree/" >tmp && grep "" tmp && grep "" tmp && grep "" tmp ' test_expect_success 'the commit page has its trailer table and diffstat' ' - more "hooks/commit/" >tmp && + cgit_rc morerc "url=hooks/commit/" >tmp && grep "
" tmp && grep "
" tmp ' test_expect_success 'the breadcrumb, the pager and the ages carry their hooks' ' - more "hooks/tree/dir/" >tmp && + cgit_rc morerc "url=hooks/tree/dir/" >tmp && grep "
" tmp && grep "" tmp ' @@ -256,7 +244,7 @@ test_expect_success 'embedded mode marks the root' ' echo "embedded=1" && cat hooksrc } >embeddedrc && - CGIT_CONFIG="$PWD/embeddedrc" QUERY_STRING="url=hooks/" cgit >tmp && + cgit_rc embeddedrc "url=hooks/" >tmp && grep "