From 7fc84f6abaac95b4c67a8fed500e5971106609d8 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 2 Nov 2026 20:49:31 -1000 Subject: Name a missing Lua module in the error log --- tests/extensions/test-about-render.lua | 7 +++++++ tests/extensions/test-email-avatar.lua | 6 ++++++ tests/extensions/test-syntax-highlight.lua | 4 ++++ tests/t0501-about-render.sh | 3 ++- tests/t0502-syntax-highlight.sh | 5 +++-- tests/t0504-email-avatar.sh | 5 +++-- 6 files changed, 25 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index 95e95bb..45cc5b3 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -24,6 +24,13 @@ end 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") +elseif has_lpeg then + h.equals("with lpeg the error log stays empty", h.error_log(), "") +end + local function render(filename, text) return h.run({ filename }, { text }) end diff --git a/tests/extensions/test-email-avatar.lua b/tests/extensions/test-email-avatar.lua index 3f14eac..aa021e2 100644 --- a/tests/extensions/test-email-avatar.lua +++ b/tests/extensions/test-email-avatar.lua @@ -26,6 +26,12 @@ end h.load(script) +if mode == "missing" then + h.contains("a missing luaossl is named in the error log", h.error_log(), "Unable to load openssl.digest") +else + h.equals("with luaossl the error log stays empty", h.error_log(), "") +end + local function render(email, name) return h.run({ email, "commit" }, { name }) end diff --git a/tests/extensions/test-syntax-highlight.lua b/tests/extensions/test-syntax-highlight.lua index a0debc6..8acbf91 100644 --- a/tests/extensions/test-syntax-highlight.lua +++ b/tests/extensions/test-syntax-highlight.lua @@ -23,9 +23,12 @@ if mode == "nolexers" then local out, ret = render("hello.fake", "if 42") h.equals("without lexers source is served escaped", out, "if 42") h.equals("close answers zero", ret, 0) + h.contains("and the error log says the lexers would not load", h.error_log(), + "Unable to load the Scintillua lexers") out = render("hello.fake", "a & c") h.equals("the fallback escapes markup", out, "a <b> & c") + h.equals("and the error log hears of it only once", h.error_log(), "") -- Large output leaves in slices, and a byte lost at a boundary would -- put the line numbers beside it out of step, so the whole escaped @@ -48,6 +51,7 @@ if mode == "nolexers" then end local out, ret = render("hello.fake", "if 42 'hi' & zz") +h.equals("loaded lexers leave the error log empty", h.error_log(), "") h.contains("keywords are wrapped in their class", out, "if") h.contains("numbers are wrapped in their class", out, "42") h.contains("a dotted tag maps by its first component", out, "'hi'") diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh index e4eaf5c..56f2e77 100755 --- a/tests/t0501-about-render.sh +++ b/tests/t0501-about-render.sh @@ -119,9 +119,10 @@ test_expect_success CGIT_LUA 'the about page shows plain text as it is' ' ' test_expect_success CGIT_LUA_NOLPEG 'without lpeg the readme is served escaped' ' - cgit_url "md/about/" >tmp && + cgit_url "md/about/" >tmp 2>err && grep "
" tmp &&
 	grep "# The Title" tmp &&
+	grep "Unable to load lpeg" err &&
 	cgit_url "man/about/" >tmp &&
 	grep "
" tmp &&
 	grep ".SH NAME" tmp
diff --git a/tests/t0502-syntax-highlight.sh b/tests/t0502-syntax-highlight.sh
index 2ca3c9f..dbb7bb0 100755
--- a/tests/t0502-syntax-highlight.sh
+++ b/tests/t0502-syntax-highlight.sh
@@ -68,9 +68,10 @@ test_expect_success CGIT_LUA 'bytes between tokens reach the page escaped' '
 # 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" \
-		QUERY_STRING="url=fake/tree/hello.fake" cgit >tmp &&
+		QUERY_STRING="url=fake/tree/hello.fake" cgit >tmp 2>err &&
 	grep "if 42 & zz" tmp &&
-	! grep "hl-keyword" tmp
+	! grep "hl-keyword" tmp &&
+	grep "Unable to load the Scintillua lexers" err
 '
 
 test_expect_success CGIT_LUA 'a lone carriage return reaches the page as an escape' '
diff --git a/tests/t0504-email-avatar.sh b/tests/t0504-email-avatar.sh
index 60db6d6..ccda85a 100755
--- a/tests/t0504-email-avatar.sh
+++ b/tests/t0504-email-avatar.sh
@@ -72,10 +72,11 @@ test_expect_success CGIT_LUA_OSSL 'the commit page draws the author icon' '
 '
 
 test_expect_success CGIT_LUA_NOOSSL 'without luaossl the page keeps the name alone' '
-	cgit_url "avatar/commit/" >tmp &&
+	cgit_url "avatar/commit/" >tmp 2>err &&
 	grep "A U Thor" tmp &&
 	! grep "