spec(object): test emit_signal protected_call

This commit is contained in:
Aire-One 2022-08-06 16:53:31 +02:00
parent f068a24bdf
commit 84712bacc2
1 changed files with 24 additions and 0 deletions

View File

@ -4,6 +4,7 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local object = require("gears.object") local object = require("gears.object")
local gdebug = require("gears.debug")
describe("gears.object", function() describe("gears.object", function()
local obj local obj
@ -185,6 +186,29 @@ describe("gears.object", function()
object{enable_auto_signals=true, enable_properties=false} object{enable_auto_signals=true, enable_properties=false}
end) end)
end) end)
it(
"signal callback with exception shouldn't break the emit_signal function",
function()
-- Stop the error reporting during tests
local orig_print_error = gdebug.print_error
gdebug.print_error = function() end
local cb = spy.new(function() end)
obj:connect_signal("error", function()
error "error"
end)
obj:connect_signal("error", function()
cb()
end)
obj:emit_signal "error"
assert.spy(cb).was_called()
-- Restore gdebug
gdebug.print_error = orig_print_error
end
)
end) end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80