test: pcall-wrap panel-spy restoration in section 12

Wraps the section-12 test body in pcall so the panel-spy
restoration runs unconditionally. Prevents spy-state leaking into
subsequent tests if section-12 fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Calic
2026-06-14 19:53:05 +02:00
parent 6f9ceebe66
commit c590196b70

View File

@@ -371,6 +371,9 @@ function M.run_tests(_ctx)
captured_entries = entries captured_entries = entries
end end
local f1_ok = false
local f2_ok = false
local body_ok, body_err = pcall(function()
-- Form-1 path -- Form-1 path
local container12a = fresh_container{ local container12a = fresh_container{
{ template = "craft_display_test.rock", count = 1 }, { template = "craft_display_test.rock", count = 1 },
@@ -380,7 +383,6 @@ function M.run_tests(_ctx)
widget12a._captured = { rid = rid, ctx_inner = ctx_inner } widget12a._captured = { rid = rid, ctx_inner = ctx_inner }
end) end)
display._invoke_context_menu(widget12a, "alias_r12", 0, 0) display._invoke_context_menu(widget12a, "alias_r12", 0, 0)
local f1_ok = false
if captured_entries and #captured_entries == 1 then if captured_entries and #captured_entries == 1 then
captured_entries[1].callback({ close_menu = function() end }) captured_entries[1].callback({ close_menu = function() end })
local cap = widget12a._captured local cap = widget12a._captured
@@ -402,7 +404,6 @@ function M.run_tests(_ctx)
widget12b._captured = { rid = rid, ctx_inner = ctx_inner } widget12b._captured = { rid = rid, ctx_inner = ctx_inner }
end) end)
display._invoke_context_menu(widget12b, "alias_r12", 0, 0) display._invoke_context_menu(widget12b, "alias_r12", 0, 0)
local f2_ok = false
if captured_entries and #captured_entries == 1 then if captured_entries and #captured_entries == 1 then
captured_entries[1].callback({ close_menu = function() end }) captured_entries[1].callback({ close_menu = function() end })
local cap = widget12b._captured local cap = widget12b._captured
@@ -411,9 +412,12 @@ function M.run_tests(_ctx)
and cap.ctx_inner.locale == locale_table12 and cap.ctx_inner.locale == locale_table12
and cap.ctx_inner.container == c12b_src2 -- sink alias and cap.ctx_inner.container == c12b_src2 -- sink alias
end end
end)
panel.show_context_menu = saved_show panel.show_context_menu = saved_show
if not body_ok then error(body_err, 0) end
T.assert(f1_ok and f2_ok, T.assert(f1_ok and f2_ok,
"12. ctx_inner carries locale + container alias: Form-1 (handle == " "12. ctx_inner carries locale + container alias: Form-1 (handle == "
.. "locale == container); Form-2 (locale==table, container==sink)") .. "locale == container); Form-2 (locale==table, container==sink)")