Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tests: SIGUSR1 sent to nvim triggers Signal event
  • Loading branch information
mhinz committed Feb 1, 2019
commit 67a2601dee2c5da8c75f5fce4ff5cc5972edcf2c
38 changes: 38 additions & 0 deletions test/functional/autocmd/signal_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
local helpers = require('test.functional.helpers')(after_each)

local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local funcs = helpers.funcs
local next_msg = helpers.next_msg

if helpers.pending_win32(pending) then
-- Only applies to POSIX systems.
return
end

local function posix_kill(signame, pid)
os.execute('kill -s '..signame..' -- '..pid..' >/dev/null')
end

describe('autocmd Signal', function()
before_each(clear)

it('matches *', function()
command('autocmd Signal * call rpcnotify(1, "foo")')
posix_kill('USR1', funcs.getpid())
eq({'notification', 'foo', {}}, next_msg())
end)

it('matches SIGUSR1', function()
command('autocmd Signal SIGUSR1 call rpcnotify(1, "foo")')
posix_kill('USR1', funcs.getpid())
eq({'notification', 'foo', {}}, next_msg())
end)

it('does not match unknown patterns', function()
command('autocmd Signal SIGUSR2 call rpcnotify(1, "foo")')
posix_kill('USR1', funcs.getpid())
eq(nil, next_msg(500))
end)
end)