comparison src/testdir/test_signals.vim @ 20373:f8835e16c34e v8.2.0742

patch 8.2.0742: handling of a TERM signal not tested Commit: https://github.com/vim/vim/commit/48a687148c4649f6f55b36a1f4111041e7207235 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 12 14:42:02 2020 +0200 patch 8.2.0742: handling of a TERM signal not tested Problem: Handling of a TERM signal not tested. Solution: Add a test for SIGTERM. (Dominique Pelle, closes https://github.com/vim/vim/issues/6055)
author Bram Moolenaar <Bram@vim.org>
date Tue, 12 May 2020 14:45:03 +0200
parents c9cc9e5c87e0
children 83f390b19223
comparison
equal deleted inserted replaced
20372:3f1e6e7f8d45 20373:f8835e16c34e
104 call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n") 104 call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n")
105 call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))}) 105 call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))})
106 106
107 call StopVimInTerminal(buf) 107 call StopVimInTerminal(buf)
108 endfunc 108 endfunc
109
110 " Test a deadly signal.
111 "
112 " There are several deadly signals: SISEGV, SIBUS, SIGTERM...
113 " Test uses signal SIGTERM as it does not create a core
114 " dump file unlike SIGSEGV, SIGBUS, etc. See "man 7 signals.
115 "
116 " Vim should exit with a deadly signal and unsaved changes
117 " should be recoverable from the swap file preserved as a
118 " result of the deadly signal handler.
119 func Test_deadly_signal_TERM()
120 if !HasSignal('TERM')
121 throw 'Skipped: TERM signal not supported'
122 endif
123 if !CanRunVimInTerminal()
124 throw 'Skipped: cannot run vim in terminal'
125 endif
126 let cmd = GetVimCommand()
127 if cmd =~ 'valgrind'
128 throw 'Skipped: cannot test signal TERM with valgrind'
129 endif
130
131 let buf = RunVimInTerminal('Xsig_TERM', {'rows': 6})
132 let pid_vim = term_getjob(buf)->job_info().process
133
134 call term_sendkeys(buf, ":call setline(1, 'foo')\n")
135 call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))})
136
137 call assert_false(filereadable('Xsig_TERM'))
138 exe 'silent !kill -s TERM ' .. pid_vim
139 call WaitForAssert({-> assert_equal('Vim: Caught deadly signal TERM', term_getline(buf, 1))})
140 call WaitForAssert({-> assert_match('Vim: preserving files\.\.\.$', term_getline(buf, 2))})
141 call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
142
143 " Don't call StopVimInTerminal() as it expects job to be still running.
144 call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
145
146 new
147 silent recover .Xsig_TERM.swp
148 call assert_equal(['foo'], getline(1, '$'))
149
150 %bwipe!
151 call delete('.Xsig_TERM.swp')
152 endfunc
153
154 " vim: ts=8 sw=2 sts=2 tw=80 fdm=marker