From 8d38a56221dff0df80fad41dc61bbc4131d96169 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 4 Nov 2026 23:13:43 -1000 Subject: Put a Lua filter's print output where it runs LuaJIT and Lua 5.1 leave print's line in stdio's buffer until cgit exits, after the end of the page. --- tests/t0201-filters.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index 8d8743a..4b39f18 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -168,4 +168,24 @@ test_expect_success CGIT_LUA 'a lua filter can encode an argument and include a grep "a+b%26c|included bold" tmp ' +# The print of LuaJIT and Lua 5.1 leaves its line in stdio's buffer, which only +# reached the page as cgit exited, behind the closing tag. A print lands where +# the filter runs. +test_expect_success CGIT_LUA 'a lua filter prints where it runs' ' + cat >print.lua <<-\EOF && + function filter_open(...) end + function filter_write(str) + print("printed", 1, nil, true) + html(str) + end + function filter_close() return 0 end + EOF + sed "s|loud.lua|print.lua|" loudrc >printrc && + cgit_rc printrc "url=foo/commit" >tmp && + tab=$(printf "\t") && + grep "
printed${tab}1${tab}nil${tab}true$" tmp && + sed -n "/<\/html>/,\$p" tmp >tail && + ! grep printed tail +' + test_done -- cgit 2.12.1