Diff options
Diffstat (limited to 'tests/t0501-about-render.sh')
-rwxr-xr-xtests/t0501-about-render.sh43
1 file changed, 41 insertions, 2 deletions
diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh
index 263c79b..339c5e2 100755
--- a/tests/t0501-about-render.sh
+++ b/tests/t0501-about-render.sh
@@ -39,7 +39,20 @@ test_expect_success 'create a repository with a markdown readme' '
See the [roadmap](ROADMAP.md#plan).
EOF
- git add README.md &&
+ cat >tool.1 <<-\EOF &&
+ .TH TOOL 1
+ .SH NAME
+ tool \- does one thing \(em well
+ .SH OPTIONS
+ .TP
+ .B \-v
+ Be \fIverbose\fR.
+ .nf
+ tool \-v <file>
+ .fi
+ EOF
+ echo "Plain <b>notes</b> & more" >NOTES &&
+ git add README.md tool.1 NOTES &&
git commit -m "add readme" &&
git branch next
)
@@ -53,11 +66,20 @@ test_expect_success 'point cgit at it through the about filter' '
repo.path=$PWD/repos/md/.git
repo.readme=:README.md
repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua
+ repo.url=man
+ repo.path=$PWD/repos/md/.git
+ repo.readme=:tool.1
+ repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua
+ repo.url=txt
+ repo.path=$PWD/repos/md/.git
+ repo.readme=:NOTES
+ repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua
EOF
'
if test "$CGIT_HAS_LUA" -eq 1
then
+ test_set_prereq CGIT_LUA
if cgit_lua_probe "$PWD/repos/md/.git" lpeg
then
test_set_prereq CGIT_LUA_LPEG
@@ -91,10 +113,27 @@ test_expect_success CGIT_LUA_LPEG 'the link stays on the branch shown' '
grep "<a href=./md/tree/ROADMAP.md?h=next#plan.>roadmap</a>" tmp
'
+test_expect_success CGIT_LUA_LPEG 'the about page renders a man page' '
+ cgit_url "man/about/" >tmp &&
+ grep "<div class=.markdown manpage.><h2 id=.name.>NAME</h2>" tmp &&
+ grep "tool - does one thing — well" tmp &&
+ grep "<strong>-v</strong><br>" tmp &&
+ grep "<pre><code>tool -v &lt;file&gt;" tmp &&
+ ! grep "\\\\f" tmp
+'
+
+test_expect_success CGIT_LUA 'the about page shows plain text as it is' '
+ cgit_url "txt/about/" >tmp &&
+ grep "<pre class=.plaintext.>Plain &lt;b&gt;notes&lt;/b&gt; &amp; more" tmp
+'
+
test_expect_success CGIT_LUA_NOLPEG 'without lpeg the readme is served escaped' '
cgit_url "md/about/" >tmp &&
grep "<pre class=.plaintext.>" tmp &&
- grep "# The Title" tmp
+ grep "# The Title" tmp &&
+ cgit_url "man/about/" >tmp &&
+ grep "<pre class=.plaintext.>" tmp &&
+ grep ".SH NAME" tmp
'
test_done