From 0c34fdf8da36da54eb0e4fc6ff2d2c27d705562b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 11:37:14 -1000 Subject: Hold the summary tests to a working page The summary requests passed on any answer short of a crash, and the checks for no tags and no commit 45 read a page another test wrote. The log checks also matched the branch row, which shows the newest subject too. Two checks under a title about the clone rows matched the vcs-git links in the head instead, and the dots in the [...] count matched any three characters. --- tests/t0102-summary.sh | 68 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'tests/t0102-summary.sh') diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh index c623202..019c8e6 100755 --- a/tests/t0102-summary.sh +++ b/tests/t0102-summary.sh @@ -8,22 +8,36 @@ test_description='Check content on summary page' . ./setup.sh -test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp' -test_expect_success 'find commit 1' 'grep "commit 1" tmp' -test_expect_success 'find commit 5' 'grep "commit 5" tmp' +# The branch row shows the newest subject as well, so the log rows are looked +# for in the log's own section. +test_expect_success 'generate foo summary' ' + cgit_ok_url "foo" >tmp && + sed -n "//,/<\/tbody>/p" tmp >log +' +test_expect_success 'find commit 1' 'test_grep ">commit 1<" log' +test_expect_success 'find commit 5' 'test_grep ">commit 5<" log' test_expect_success 'find branch master' 'grep "]*>master" tmp' -test_expect_success 'no tags' '! grep "Tag" tmp' +test_expect_success 'a repository without tags draws no tag table' ' + cgit_ok_url "foo" >tmp && + test_grep "" tmp && + test_grep ! "Tag" tmp +' test_expect_success 'clone-url expanded correctly' ' grep "git://example.org/foo.git" tmp ' -test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp' +test_expect_success 'generate bar summary' ' + cgit_ok_url "bar" >tmp && + sed -n "//,/<\/tbody>/p" tmp >log +' test_expect_success 'repo description reaches the meta tag' ' grep "" tmp ' -test_expect_success 'no commit 45' '! grep "commit 45" tmp' -test_expect_success 'find commit 46' 'grep "commit 46" tmp' -test_expect_success 'find commit 50' 'grep "commit 50" tmp' +test_expect_success 'the summary log stops at summary-log commits' ' + test_grep ">commit 46<" log && + test_grep ! ">commit 45<" log +' +test_expect_success 'find commit 50' 'test_grep ">commit 50<" log' # A clone url is shown as written, but a browser cannot follow the ssh, scp # or git forms, so those rows link to the first http url in the list, or to @@ -34,10 +48,16 @@ test_expect_success 'a git clone url row falls back to the page url' ' test_expect_success 'an scp clone url row links to the http url' ' cgitrc_repo clonerc foo "repo.clone-url=git@example.org:foo https://example.org/foo" && - cgit_rc clonerc "url=foo" >tmp && - grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo" tmp && - grep "vcs-git. href=.https://example.org/foo." tmp && - ! grep "vcs-git. href=.git@" tmp + cgit_ok clonerc "url=foo" >tmp && + grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo" tmp +' + +# A link element's href has to hold a URI, so the scp form is left out of +# the head while the http url gets a link there. +test_expect_success 'the head links only the clone urls with a scheme' ' + cgit_ok clonerc "url=foo" >tmp && + test_grep "" tmp && + test_grep ! "emptyrc && - cgit_rc emptyrc "url=foo" >tmp && - grep "commit 1" tmp && - ! grep "Clone" tmp && - cgit_rc emptyrc "url=empty" >tmp && - grep "Repository seems to be empty" tmp && - ! grep "Clone" tmp && - cgit_rc emptyrc "url=cloned" >tmp && + cgit_ok emptyrc "url=foo" >tmp && + test_grep ">commit 1<" tmp && + test_grep ! "Clone" tmp && + cgit_ok emptyrc "url=empty" >tmp && + test_grep "Repository seems to be empty" tmp && + test_grep ! "Clone" tmp && + cgit_ok emptyrc "url=cloned" >tmp && grep "Clone" tmp && grep "https://example.org/cloned" tmp ' @@ -92,7 +112,7 @@ row_widths() { # Fails unless every row of the list table at the url is as many columns wide # as the second argument says. A third names a config other than colsrc. test_widths() { - cgit_rc "${3:-colsrc}" "url=$1" >tmp && + cgit_ok "${3:-colsrc}" "url=$1" >tmp && row_widths tmp | sort -u >actual && echo "$2" >expect && test_cmp expect actual @@ -126,10 +146,10 @@ test_expect_success 'set up a repo cut short in every section' ' echo "repo.enable-log-filecount=1" && echo "repo.enable-log-linecount=1" } >colsrc && - cgit_rc colsrc "url=none" >tmp && + cgit_ok colsrc "url=none" >tmp && grep "" tmp && grep "" tmp && - test $(grep -c ">\[...\]" tmp) = 3 + test $(grep -c ">\[\.\.\.\]" tmp) = 3 ' test_expect_success 'a summary without counts fills four columns' 'test_widths none 4' @@ -149,13 +169,13 @@ test_expect_success 'a page of tags fills four columns' 'test_widths both/refs/t # The tag table's second column holds the downloads, or with no snapshot # format the object each tag points at, and is headed for what it holds. test_expect_success 'the tag table heads its second column for what it holds' ' - cgit_rc colsrc "url=none/refs/" >tmp && + cgit_ok colsrc "url=none/refs/" >tmp && grep "TagCommit" tmp && { echo "snapshots=tar" && cat colsrc } >snaprc && - cgit_rc snaprc "url=none/refs/" >tmp && + cgit_ok snaprc "url=none/refs/" >tmp && grep "TagDownload" tmp ' -- cgit 2.12.1