Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hold the log tests to a working page
The log requests passed on any answer short of a crash. The search
checks after the first read a page an earlier test wrote, so run alone
they passed with no page at all, and three tests shared one title. The
switcher checks found the right option selected but not that it was
the only one, and a failed check left its tag behind for the tests
after it. The broken walk's log was written and never read.
| -rwxr-xr-x | tests/t0103-log.sh | 90 |
1 file changed, 54 insertions, 36 deletions
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index 444db8f..16fc6e9 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -7,52 +7,70 @@ test_description='Check content on log page' . ./setup.sh -test_expect_success 'generate foo/log' 'cgit_url "foo/log" >tmp' -test_expect_success 'find commit 1' 'grep "commit 1" tmp' -test_expect_success 'find commit 5' 'grep "commit 5" tmp' +test_expect_success 'the log lists the whole of a short history' ' + cgit_ok_url "foo/log" >tmp && + test_grep ">commit 1<" tmp && + test_grep ">commit 5<" tmp +' + +test_expect_success 'the first log page holds fifty commits' ' + cgit_ok_url "bar/log" >tmp && + test_grep ">commit 1<" tmp && + test_grep ">commit 50<" tmp +' -test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp' -test_expect_success 'find commit 1' 'grep ">commit 1<" tmp' -test_expect_success 'find commit 50' 'grep "commit 50" tmp' +# Prints the options of the branch switcher that carry selected. +selected_options() { + sed -n "/<select name=.h./,/<\/select>/p" "$1" | grep " selected" +} # The switch button submits the select as h, so whatever head the request # follows has to sit in the list selected, or submitting would quietly move # the visitor to the first branch. test_expect_success 'a detached head stays selected in the switcher' ' sha=$(git -C repos/foo rev-parse master~1) && - cgit_url "foo/log&h=$sha" >tmp && - grep "option value=.$sha. selected" tmp + cgit_ok_url "foo/log&h=$sha" >tmp && + selected_options tmp >selected && + test_line_count = 1 selected && + test_grep "option value=.$sha. selected" selected ' test_expect_success 'a tag head stays selected in the switcher' ' git -C repos/foo tag t-switch master~1 && - cgit_url "foo/log&h=t-switch" >tmp && - grep "option value=.t-switch. selected>t-switch (detached)" tmp && - git -C repos/foo tag -d t-switch + test_when_finished "git -C repos/foo tag -d t-switch" && + cgit_ok_url "foo/log&h=t-switch" >tmp && + selected_options tmp >selected && + test_line_count = 1 selected && + test_grep "option value=.t-switch. selected>t-switch (detached)" selected ' test_expect_success 'a branch head keeps its plain option' ' - cgit_url "foo/log&h=master" >tmp && - grep "option value=.master. selected>master<" tmp && - ! grep "detached" tmp + cgit_ok_url "foo/log&h=master" >tmp && + selected_options tmp >selected && + test_line_count = 1 selected && + test_grep "option value=.master. selected>master<" selected && + test_grep ! "detached" tmp ' -test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' ' - cgit_url "with+space/log&qt=grep&q=commit+1" >tmp +test_expect_success 'a search escapes the space in its links' ' + cgit_ok_url "with+space/log&qt=grep&q=commit+1" >tmp && + test_grep "/with%20space/log/?qt=grep" tmp && + test_grep "/log/?qt=grep&q=commit+1" tmp && + test_grep ! "href=./with space/" tmp && + test_grep ! "q=commit 1" tmp +' +test_expect_success 'a search lists only the commits it matches' ' + cgit_ok_url "with+space/log&qt=grep&q=commit+1" >tmp && + test_grep ">commit 1<" tmp && + test_grep ! "commit 2" tmp ' -test_expect_success 'find commit 1' 'grep ">commit 1<" tmp' -test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" tmp' -test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" tmp' -test_expect_success 'no links with space in path' '! grep "href=./with space/" tmp' -test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp' -test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp' # A search that matches nothing says so in a row of its own, rather than # leaving the table a header with nothing under it. test_expect_success 'a search matching nothing says so' ' - cgit_url "foo/log&qt=grep&q=no+such+commit" >tmp && - grep "^Status: 200" tmp && - grep "<tr class=.nohover.><td colspan=.5.>No commits match the search</td></tr>" tmp && - cgit_url "foo/log&qt=grep&q=commit+1" >tmp && - ! grep "No commits match" tmp + cgit_ok_url "foo/log&qt=grep&q=no+such+commit" >tmp && + test_grep "<tr class=.nohover.><td colspan=.5.>No commits match the search</td></tr>" tmp && + cgit_ok_url "foo/log&qt=grep&q=commit+1" >tmp && + test_grep ">commit 1<" tmp && + test_grep ! "No commits match" tmp ' # Following a file diffs each commit for the name the file had there, so the @@ -82,13 +100,13 @@ test_expect_success 'set up a renamed file to follow' ' ' test_expect_success 'a followed log reaches the root commit' ' - cgit_rc folrc "url=fol/log/b.txt&follow=1&ofs=6" >tmp && + cgit_ok folrc "url=fol/log/b.txt&follow=1&ofs=6" >tmp && grep ">edit a 2<" tmp && grep ">create a<" tmp ' test_expect_success 'the pager of a followed log keeps the name followed' ' - cgit_rc folrc "url=fol/log/b.txt&follow=1&ofs=3" >tmp && + cgit_ok folrc "url=fol/log/b.txt&follow=1&ofs=3" >tmp && grep ">edit a 3<" tmp && grep "href=./fol/log/b.txt?follow=1.>\[prev\]" tmp && grep "href=./fol/log/b.txt?ofs=6&follow=1.>\[next\]" tmp @@ -97,13 +115,13 @@ test_expect_success 'the pager of a followed log keeps the name followed' ' test_expect_success 'a cut subject keeps whole characters' ' git -C repos/foo commit --allow-empty -m "日本語の説明文です日本語の説明文です" && cgitrc_copy subjectrc max-message-length=20 && - cgit_rc subjectrc "url=foo/log/" >tmp && + cgit_ok subjectrc "url=foo/log/" >tmp && grep ">日本語の説\.\.\.</a>" tmp ' test_expect_success 'the log draws the commit graph when enabled' ' cgitrc_copy graphrc enable-commit-graph=1 && - cgit_rc graphrc "url=foo/log/" >tmp && + cgit_ok graphrc "url=foo/log/" >tmp && grep "class=.commitgraph." tmp && grep "<th scope=.col. aria-label=.Graph.></th>" tmp ' @@ -115,17 +133,16 @@ test_expect_success 'a followed log heads its age column with the graph on' ' echo "enable-commit-graph=1" && cat folrc } >folgraphrc && - cgit_rc folgraphrc "url=fol/log/b.txt&follow=1" >tmp && + cgit_ok folgraphrc "url=fol/log/b.txt&follow=1" >tmp && grep "<th class=.left. scope=.col.>Age</th><th class=.left. scope=.col.>Commit message" tmp && - ! grep "aria-label=.Graph." tmp + test_grep ! "aria-label=.Graph." tmp ' # The search is literal, so text that is no valid regular expression still # finds the commit holding it. test_expect_success 'a search for brackets matches them literally' ' git -C repos/foo commit --allow-empty -m "fix [brackets] in docs" && - cgit_url "foo/log&qt=grep&q=%5Bbrackets" >tmp && - grep "^Status: 200" tmp && + cgit_ok_url "foo/log&qt=grep&q=%5Bbrackets" >tmp && grep "fix \\[brackets\\] in docs" tmp ' @@ -140,7 +157,8 @@ test_expect_success 'a walk that cannot start answers one error page' ' cgit_rc gaprc "url=gap/log/&qt=range&q=$old..master" >tmp 2>err && test $(grep -c "^Status:" tmp) = 1 && grep "^Status: 500" tmp && - grep "Unable to read the history" tmp + grep "Unable to read the history" tmp && + test_grep "Could not read $parent" err ' test_done |
