From 6583af9ae6ee8adf9cd810b39fd15a32c10953d2 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 10:30:19 -1000 Subject: Check the log line for lexers that are not found Every check set CGIT_SCINTILLUA_PATH, which the filter takes as given, so the line for a server with no Scintillua at all never ran and deleting it passed. The harness can now clear a variable and hide the directories the filter probes. A lexer.lua anywhere on LUA_PATH also loaded in place of the missing one, so the fallback runs now keep every Lua module out of reach. --- tests/t0502-syntax-highlight.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'tests/t0502-syntax-highlight.sh') diff --git a/tests/t0502-syntax-highlight.sh b/tests/t0502-syntax-highlight.sh index 3e32e3b..c0b4480 100755 --- a/tests/t0502-syntax-highlight.sh +++ b/tests/t0502-syntax-highlight.sh @@ -1,14 +1,15 @@ #!/bin/sh # Checks syntax-highlight.lua, the shipped source-filter. The real Scintillua -# collection is not assumed anywhere, because the fake lexer module under -# extensions/fake-lexers drives every path through the filter -# deterministically. The unit checks run twice per interpreter, once with the -# fake lexers found and once with an empty directory so the escaped fallback -# is what everything renders through. The run through cgit itself places the -# fake lexers beside the config file, which is the probe the filter documents -# for a scintillua directory next to cgitrc, and then points the lexer path -# at nothing to see the page fall back to escaped text. +# collection is not assumed anywhere. The fake lexer module under +# extensions/fake-lexers stands in for a working one, and the fallback +# checks keep every lexer the filter could find out of its reach. The unit +# checks run twice per interpreter, once with the fake lexers found and once +# without any, so the escaped fallback is what everything renders through. +# The run through cgit itself places the fake lexers beside the config file, +# which is the probe the filter documents for a scintillua directory next to +# cgitrc, and then points the lexer path at nothing to see the page fall back +# to escaped text. test_description='Check the shipped syntax-highlight extension' CGIT_TEST_NO_CREATE_REPOS=YesPlease @@ -25,7 +26,7 @@ do test_expect_success STANDALONE_LUA "fallback checks without lexers under $(lua_version "$lua")" ' mkdir -p empty-lexers && - CGIT_SCINTILLUA_PATH="$PWD/empty-lexers" \ + without_lua_modules env CGIT_SCINTILLUA_PATH="$PWD/empty-lexers" \ "$lua" "$EXT_TEST_DIRECTORY/test-syntax-highlight.lua" \ "$EXTENSIONS_DIRECTORY/syntax-highlight.lua" nolexers ' @@ -69,11 +70,14 @@ test_expect_success CGIT_LUA 'bytes between tokens reach the page escaped' ' # a filter that failed there would take the whole page down with it, so it # has to hand the source back escaped instead. test_expect_success CGIT_LUA 'without scintillua the source is served escaped' ' - CGIT_SCINTILLUA_PATH=/nonexistent CGIT_CONFIG="$PWD/cgitrc" \ + echo "[cgit] Unable to load the Scintillua lexers: module ${SQ}lexer${SQ} not found:" >expect && + without_lua_modules env CGIT_SCINTILLUA_PATH=/nonexistent CGIT_CONFIG="$PWD/cgitrc" \ QUERY_STRING="url=fake/tree/hello.fake" cgit >tmp 2>err && - grep "if 42 & zz" tmp && - ! grep "hl-keyword" tmp && - grep "Unable to load the Scintillua lexers" err + test_cmp expect err && + test_grep "^Status: 200" tmp && + test_grep "" tmp && + test_grep "if 42 & zz" tmp && + test_grep ! "hl-keyword" tmp ' test_expect_success CGIT_LUA 'a lone carriage return reaches the page as an escape' ' -- cgit 2.12.1