Skip to content

Commit 11df378

Browse files
committed
[tests] lua: make sure lua logging functions don't break request handling
Change-Id: Ia43aec68b4ae7f18e8925d18665cc65e86f8e621
1 parent a9e4f09 commit 11df378

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/pylt/tests/t-lua.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88
-- globals should be reset after loading
99
info = "global info"
1010
11+
-- tostring(custom_obj) should throw an error, but log functions should handle it
12+
local custom_obj = {["data"] = "test string"}
13+
setmetatable(custom_obj, {["__tostring"] = function(obj) return nil .. obj["data"] end})
14+
15+
print("bar", "custom_obj=", custom_obj)
16+
1117
local function extract_info(vr)
18+
vr:error("extract_info: info=" .. (info or ""), "nil=", nil, "custom_obj=", custom_obj)
1219
-- simple globals should be "per handler" (and request)
1320
info = (info or "") .. "handler global"
1421
-- special `REQ` allows request-global state across handlers
1522
REQ.info = (REQ.info or "") .. "request global:" .. vr.env["INFO"]
1623
end
1724
1825
local function show_info(vr)
26+
lighty.error("show_info: info=" .. (info or "") .. "; REQ.info=" .. (REQ.info or ""))
1927
if vr:handle_direct() then
2028
vr.resp.status = 200
2129
vr.resp.headers["Content-Type"] = "text/plain"

0 commit comments

Comments
 (0)