mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #29739 from zeertzjq/vim-8.2.5158
vim-patch:8.2.{2276,5158},9.0.0393
This commit is contained in:
@@ -86,26 +86,73 @@ func Test_signal_INT()
|
|||||||
throw 'Skipped: INT signal not supported'
|
throw 'Skipped: INT signal not supported'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Skip the rest of the test when running with valgrind as signal INT is not
|
|
||||||
" received somehow by Vim when running with valgrind.
|
|
||||||
let cmd = GetVimCommand()
|
|
||||||
if cmd =~ 'valgrind'
|
|
||||||
throw 'Skipped: cannot test signal INT with valgrind'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let buf = RunVimInTerminal('', {'rows': 6})
|
let buf = RunVimInTerminal('', {'rows': 6})
|
||||||
let pid_vim = term_getjob(buf)->job_info().process
|
let pid_vim = term_getjob(buf)->job_info().process
|
||||||
|
|
||||||
" Check that an endless loop in Vim is interrupted by signal INT.
|
" Check that an endless loop in Vim is interrupted by signal INT.
|
||||||
|
call term_sendkeys(buf, ":call setline(1, 'running')\n")
|
||||||
call term_sendkeys(buf, ":while 1 | endwhile\n")
|
call term_sendkeys(buf, ":while 1 | endwhile\n")
|
||||||
call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))})
|
call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))})
|
||||||
exe 'silent !kill -s INT ' .. pid_vim
|
exe 'silent !kill -s INT ' .. pid_vim
|
||||||
|
sleep 50m
|
||||||
call term_sendkeys(buf, ":call setline(1, 'INTERRUPTED')\n")
|
call term_sendkeys(buf, ":call setline(1, 'INTERRUPTED')\n")
|
||||||
call WaitForAssert({-> assert_equal('INTERRUPTED', term_getline(buf, 1))})
|
call WaitForAssert({-> assert_equal('INTERRUPTED', term_getline(buf, 1))})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test signal TSTP. Handler sets got_tstp.
|
||||||
|
func Test_signal_TSTP()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
if !HasSignal('TSTP')
|
||||||
|
throw 'Skipped: TSTP signal not supported'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If test fails once, it can leave temporary files and trying to rerun
|
||||||
|
" the test would then fail again if they are not deleted first.
|
||||||
|
call delete('.Xsig_TERM.swp')
|
||||||
|
call delete('XsetupAucmd')
|
||||||
|
call delete('XautoOut1')
|
||||||
|
call delete('XautoOut2')
|
||||||
|
let lines =<< trim END
|
||||||
|
au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut1", "as")
|
||||||
|
au VimResume * call writefile(["VimResume triggered"], "XautoOut2", "as")
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XsetupAucmd')
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
|
||||||
|
let pid_vim = term_getjob(buf)->job_info().process
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":call setline(1, 'foo')\n")
|
||||||
|
call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))})
|
||||||
|
|
||||||
|
call assert_false(filereadable('Xsig_TERM'))
|
||||||
|
|
||||||
|
" After TSTP the file is not saved (same function as ^Z)
|
||||||
|
exe 'silent !kill -s TSTP ' .. pid_vim
|
||||||
|
call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
|
||||||
|
sleep 100m
|
||||||
|
|
||||||
|
" We resume after the suspend. Sleep a bit for the signal to take effect,
|
||||||
|
" also when running under valgrind.
|
||||||
|
exe 'silent !kill -s CONT ' .. pid_vim
|
||||||
|
call WaitForAssert({-> assert_true(filereadable('XautoOut2'))})
|
||||||
|
sleep 10m
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
|
||||||
|
let result = readfile('XautoOut1')
|
||||||
|
call assert_equal(["VimSuspend triggered"], result)
|
||||||
|
let result = readfile('XautoOut2')
|
||||||
|
call assert_equal(["VimResume triggered"], result)
|
||||||
|
|
||||||
|
%bwipe!
|
||||||
|
call delete('.Xsig_TERM.swp')
|
||||||
|
call delete('XsetupAucmd')
|
||||||
|
call delete('XautoOut1')
|
||||||
|
call delete('XautoOut2')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test a deadly signal.
|
" Test a deadly signal.
|
||||||
"
|
"
|
||||||
" There are several deadly signals: SISEGV, SIBUS, SIGTERM...
|
" There are several deadly signals: SISEGV, SIBUS, SIGTERM...
|
||||||
@@ -120,10 +167,6 @@ func Test_deadly_signal_TERM()
|
|||||||
throw 'Skipped: TERM signal not supported'
|
throw 'Skipped: TERM signal not supported'
|
||||||
endif
|
endif
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
let cmd = GetVimCommand()
|
|
||||||
if cmd =~ 'valgrind'
|
|
||||||
throw 'Skipped: cannot test signal TERM with valgrind'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" If test fails once, it can leave temporary files and trying to rerun
|
" If test fails once, it can leave temporary files and trying to rerun
|
||||||
" the test would then fail again if they are not deleted first.
|
" the test would then fail again if they are not deleted first.
|
||||||
|
Reference in New Issue
Block a user