diff options
Diffstat (limited to 'src/testdir/test_signals.vim')
-rw-r--r-- | src/testdir/test_signals.vim | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/testdir/test_signals.vim b/src/testdir/test_signals.vim index 72fd02433..d3a4d89ce 100644 --- a/src/testdir/test_signals.vim +++ b/src/testdir/test_signals.vim @@ -105,6 +105,58 @@ func Test_signal_INT() call StopVimInTerminal(buf) endfunc +" Test signal TSTP. Handler sets got_tstp. +func Test_signal_TSTP() + CheckRunVimInTerminal + if !HasSignal('TSTP') + throw 'Skipped: TSTP signal not supported' + endif + + " Skip the test when running with valgrind as signal TSTP is not received + " somehow by Vim when running with valgrind. + let cmd = GetVimCommand() + if cmd =~ 'valgrind' + throw 'Skipped: cannot test signal TSTP with valgrind' + 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('XautoOut') + let lines =<< trim END + au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut", "as") + au VimResume * call writefile(["VimResume triggered"], "XautoOut", "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'))}) + + " We resume after the suspend + exe 'silent !kill -s CONT ' .. pid_vim + exe 'silent !sleep 0.006' + + call StopVimInTerminal(buf) + + let result = readfile('XautoOut') + call assert_equal(["VimSuspend triggered", "VimResume triggered"], result) + + %bwipe! + call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') +endfunc + " Test a deadly signal. " " There are several deadly signals: SISEGV, SIBUS, SIGTERM... |