Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Prove the about page fallback on any machine
The fallback through cgit ran only where cgit's own Lua lacked lpeg,
and every machine the suite runs on has it, so the test never ran.
With every Lua search path pointed at an empty directory it runs
anywhere. It now also checks that the readme's markup is escaped, as
its title said, and compares the whole log line.
Diffstat (limited to 'tests/t0501-about-render.sh')
| -rwxr-xr-x | tests/t0501-about-render.sh | 33 |
1 file changed, 19 insertions, 14 deletions
diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh index af68260..d432dd2 100755 --- a/tests/t0501-about-render.sh +++ b/tests/t0501-about-render.sh @@ -5,8 +5,9 @@ # extensions/, once with lpeg wherever that interpreter has it and once with # lpeg forced away so the plain text fallback is proven everywhere. A # repository with a markdown readme is then rendered through cgit itself, -# where the outcome depends on whether the Lua inside the binary has lpeg, so -# a probe decides which of the two right answers to expect. +# with lpeg wherever a probe finds it in the Lua inside the binary, and with +# every Lua module kept off the search path, which gives the fallback on any +# machine. test_description='Check the shipped about-render extension' CGIT_TEST_NO_CREATE_REPOS=YesPlease @@ -77,10 +78,6 @@ test_expect_success 'point cgit at it through the about filter' ' if cgit_lua_probe "$PWD/repos/md/.git" lpeg then test_set_prereq CGIT_LUA_LPEG -elif test "$CGIT_HAS_LUA" -eq 1 -then - test_set_prereq CGIT_LUA_NOLPEG - say 'cgit lua has no lpeg, expecting the plain text fallback' fi test_expect_success CGIT_LUA_LPEG 'the about page renders the markdown' ' @@ -119,14 +116,22 @@ test_expect_success CGIT_LUA_LPEG 'the about page shows plain text as it is' ' test_grep "<pre class=.plaintext.>Plain <b>notes</b> & more" tmp ' -test_expect_success CGIT_LUA_NOLPEG 'without lpeg the readme is served escaped' ' - cgit_url "md/about/" >tmp 2>err && - grep "<pre class=.plaintext.>" tmp && - grep "# The Title" tmp && - grep "Unable to load lpeg" err && - cgit_url "man/about/" >tmp && - grep "<pre class=.plaintext.>" tmp && - grep ".SH NAME" tmp +test_expect_success CGIT_LUA 'without lpeg every readme is served escaped' ' + echo "[cgit] Unable to load lpeg, so markdown and man pages show as plain text" >expect && + without_lua_modules cgit_url "md/about/" >tmp 2>err && + test_cmp expect err && + test_grep "^Status: 200" tmp && + test_grep "</html>" tmp && + test_grep "<pre class=.plaintext.># The Title" tmp && + test_grep "<script>alert(1)</script>" tmp && + test_grep ! "<script>alert(1)" tmp && + without_lua_modules cgit_url "man/about/" >tmp 2>err && + test_cmp expect err && + test_grep "<pre class=.plaintext.>\.TH TOOL 1" tmp && + test_grep -F ".SH NAME" tmp && + without_lua_modules cgit_url "txt/about/" >tmp 2>err && + test_cmp expect err && + test_grep "<pre class=.plaintext.>Plain <b>notes</b> & more" tmp ' test_done |
