Mercurial > vim
diff src/testdir/test_signals.vim @ 19754:c9cc9e5c87e0 v8.2.0433
patch 8.2.0433: INT signal not properly tested
Commit: https://github.com/vim/vim/commit/bad8804cdd739a5a7321b8411ad7fd4f45741b54
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 23 20:54:32 2020 +0100
patch 8.2.0433: INT signal not properly tested
Problem: INT signal not properly tested.
Solution: Add a test. Also clean up some unnecessary lines. (Dominique
Pelle, closes #5828)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 23 Mar 2020 21:00:04 +0100 |
parents | 0da9bc55c31a |
children | f8835e16c34e |
line wrap: on
line diff
--- a/src/testdir/test_signals.vim +++ b/src/testdir/test_signals.vim @@ -1,6 +1,8 @@ " Test signal handling. source check.vim +source term_util.vim + CheckUnix source shared.vim @@ -50,7 +52,7 @@ endfunc " Test signal PWR, which should update the swap file. func Test_signal_PWR() if !HasSignal('PWR') - return + throw 'Skipped: PWR signal not supported' endif " Set a very large 'updatetime' and 'updatecount', so that we can be sure @@ -75,3 +77,32 @@ func Test_signal_PWR() bwipe! set updatetime& updatecount& endfunc + +" Test signal INT. Handler sets got_int. It should be like typing CTRL-C. +func Test_signal_INT() + if !HasSignal('INT') + throw 'Skipped: INT signal not supported' + 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 + + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let buf = RunVimInTerminal('', {'rows': 6}) + let pid_vim = term_getjob(buf)->job_info().process + + " Check that an endless loop in Vim is interrupted by signal INT. + call term_sendkeys(buf, ":while 1 | endwhile\n") + call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))}) + exe 'silent !kill -s INT ' .. pid_vim + call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n") + call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))}) + + call StopVimInTerminal(buf) +endfunc