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/t0005-markup.sh')
| -rwxr-xr-x | tests/t0005-markup.sh | 74 |
1 file changed, 31 insertions, 43 deletions
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 "<div id=.cgit. data-page=.repolist.>" tmp && - hooks "hooks/log/" >tmp && + cgit_rc hooksrc "url=hooks/log/" >tmp && grep "<div id=.cgit. data-page=.log. data-repo=.hooks.>" 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 "<meta name=.generator. content=.cgit.>" footer && grep "<footer class=.footer.>generated by <a href=[^>]*>cgit</a></footer>" 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 "<meta name=.generator. content=.cgit v[0-9][^>]*>" footer && grep "<footer class=.footer.>generated by <a href=[^>]*>cgit v[0-9][^<]*</a> (<a href=[^>]*>git [0-9][^<]*</a>)</footer>" footer && echo "<footer>our own</footer>" >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 "<footer>our own</footer>" footer && ! grep "git-scm" footer ' @@ -73,58 +63,58 @@ test_expect_success 'the listings name themselves, their sections and their rows grep "<tr class=.commit.>" tmp && grep "class=.active. aria-current=.page." tmp && grep "<th class=.left. scope=.col.>" tmp && - hooks "" >tmp && + cgit_rc hooksrc "url=" >tmp && grep "<table class=.list repolist. aria-label=.Repositories.>" tmp && grep "<tbody class=.repos.>" tmp && grep "<tr class=.repo.>" tmp && - hooks "hooks/" >tmp && + cgit_rc hooksrc "url=hooks/" >tmp && grep "<table class=.list summary. aria-label=.Summary.>" tmp && grep "<tbody class=.branches.>" tmp && grep "<tr class=.branch.>" tmp && - hooks "hooks/tree/" >tmp && + cgit_rc hooksrc "url=hooks/tree/" >tmp && grep "<table class=.list tree. aria-label=.Files.>" tmp && grep "<tr class=.dir.>" tmp && grep "<tr class=.blob.>" 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 "<table class=.commit-info.>" tmp && grep "<th scope=.row.>author</th>" tmp && grep "<div class=.file. data-path=.dir/hello.c.>" tmp && grep "<label for=.diff-context.>context</label>" tmp && grep "<select id=.diff-context. name=.context.>" tmp && grep "<form method=.get. aria-label=.Diff options.>" tmp && - hooks "hooks/diff/&ss=1" >tmp && + cgit_rc hooksrc "url=hooks/diff/&ss=1" >tmp && grep "<tbody class=.file. data-path=.dir/hello.c.>" tmp && - hooks "hooks/stats/" >tmp && + cgit_rc hooksrc "url=hooks/stats/" >tmp && grep "<label for=.stats-authors.>authors</label>" 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 "<div class=.blob-header.>" tmp && grep "<a id=.n1." tmp && - hooks "hooks/blame/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/blame/dir/hello.c" >tmp && grep "<div class=.blob-header.>" tmp && - hooks "hooks/about/" >tmp && + cgit_rc hooksrc "url=hooks/about/" >tmp && grep "<div id=.about.>" 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 "<title>hooks - $site</title>" tmp && for page in about log refs tree stats do - hooks "hooks/$page/" >tmp && + cgit_rc hooksrc "url=hooks/$page/" >tmp && grep "<title>$page - hooks - $site</title>" tmp || return 1 done && - hooks "hooks/tree/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/tree/dir/hello.c" >tmp && grep "<title>hello.c < dir - hooks - $site</title>" tmp && - hooks "hooks/blame/dir/hello.c" >tmp && + cgit_rc hooksrc "url=hooks/blame/dir/hello.c" >tmp && grep "<title>blame - hello.c < dir - hooks - $site</title>" 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 "<script src=./cgit.js. defer></script>" 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 "<table class=.list refs. aria-label=.Branches and tags.>" tmp && grep "<tbody class=.tags.>" tmp && grep "<tr class=.tag.>" tmp && - more "hooks/" >tmp && + cgit_rc morerc "url=hooks/" >tmp && grep "<tbody class=.clone.>" tmp && - more "hooks/tree/" >tmp && + cgit_rc morerc "url=hooks/tree/" >tmp && grep "<tbody class=.tree.>" tmp && grep "<tr class=.link.>" tmp && grep "<tr class=.mod.>" 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 "<table class=.commit-trailers.>" tmp && grep "<table class=.diffstat.>" 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 "<nav class=.path. aria-label=.breadcrumb.>" tmp && - more "" >tmp && + cgit_rc morerc "url=" >tmp && grep "<nav class=.pager. aria-label=.Pager.>" tmp && grep "class=.current. aria-current=.page." tmp && grep "<time class=.age-[a-z]*. datetime=.[^ ]* data-ut=.[0-9]*." tmp @@ -240,13 +228,13 @@ test_expect_success 'a date shown in full is a plain time element' ' echo "enable-relative-dates=0" && cat morerc } >fullrc && - CGIT_CONFIG="$PWD/fullrc" QUERY_STRING="url=" cgit >tmp && + cgit_rc fullrc "url=" >tmp && grep "<time datetime=" tmp && ! grep "data-ut=" tmp ' test_expect_success 'an empty repository lists its clone urls as a clone table' ' - more "empty/" >tmp && + cgit_rc morerc "url=empty/" >tmp && grep "<table class=.list clone. aria-label=.Clone urls.>" tmp && grep "<tbody class=.clone.>" 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 "<div id=.cgit. class=.cgit-embedded. data-page=.summary." tmp ' |
