From 8b8f559e87e31559342479045ae5856c1ab2cb8e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 10:23:29 -1000 Subject: 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. --- tests/extensions/lib.sh | 22 ++++++++++++++++++++++ tests/extensions/test-about-render.lua | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'tests/extensions') diff --git a/tests/extensions/lib.sh b/tests/extensions/lib.sh index 56098d0..041a042 100644 --- a/tests/extensions/lib.sh +++ b/tests/extensions/lib.sh @@ -67,6 +67,28 @@ lua_module_prereq() { fi } +# Runs the command given with every Lua search path pointed at an empty +# directory, so no Lua it starts, cgit's own included, finds a module that +# is not built in. A fallback for a missing module then runs on any machine. +without_lua_modules() { + mkdir -p "$TRASH_DIRECTORY/no-lua-modules" && + ( + for lua_variable in LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 \ + LUA_PATH_5_4 LUA_PATH_5_5 + do + eval "$lua_variable=\$TRASH_DIRECTORY/no-lua-modules/?.lua" + export $lua_variable + done + for lua_variable in LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 \ + LUA_CPATH_5_4 LUA_CPATH_5_5 + do + eval "$lua_variable=\$TRASH_DIRECTORY/no-lua-modules/?.so" + export $lua_variable + done + "$@" + ) +} + # Asks whether cgit's own Lua can require every module named, by pointing a # throwaway commit-filter at the given repository and reading its answer off # the rendered commit page. Filters need a page to run on, which is why a diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index e6813ef..7d714c3 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -19,7 +19,8 @@ h.load(script) -- A missing lpeg is written to the error log as the script loads. if mode == "nolpeg" then - h.contains("a missing lpeg is named in the error log", h.error_log(), "Unable to load lpeg") + h.equals("a missing lpeg is named in the error log", h.error_log(), + "[cgit] Unable to load lpeg, so markdown and man pages show as plain text\n") else h.equals("with lpeg the error log stays empty", h.error_log(), "") end -- cgit 2.12.1