Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
19753:cf2885e38afd | 19754:c9cc9e5c87e0 |
---|---|
1 " Test signal handling. | 1 " Test signal handling. |
2 | 2 |
3 source check.vim | 3 source check.vim |
4 source term_util.vim | |
5 | |
4 CheckUnix | 6 CheckUnix |
5 | 7 |
6 source shared.vim | 8 source shared.vim |
7 | 9 |
8 " Check whether a signal is available on this system. | 10 " Check whether a signal is available on this system. |
48 endfunc | 50 endfunc |
49 | 51 |
50 " Test signal PWR, which should update the swap file. | 52 " Test signal PWR, which should update the swap file. |
51 func Test_signal_PWR() | 53 func Test_signal_PWR() |
52 if !HasSignal('PWR') | 54 if !HasSignal('PWR') |
53 return | 55 throw 'Skipped: PWR signal not supported' |
54 endif | 56 endif |
55 | 57 |
56 " Set a very large 'updatetime' and 'updatecount', so that we can be sure | 58 " Set a very large 'updatetime' and 'updatecount', so that we can be sure |
57 " that swap file is updated as a result of sending PWR signal, and not | 59 " that swap file is updated as a result of sending PWR signal, and not |
58 " because of exceeding 'updatetime' or 'updatecount' when changing buffer. | 60 " because of exceeding 'updatetime' or 'updatecount' when changing buffer. |
73 call WaitForAssert({-> assert_notequal(swap_content, readfile(swap_name, 'b'))}) | 75 call WaitForAssert({-> assert_notequal(swap_content, readfile(swap_name, 'b'))}) |
74 | 76 |
75 bwipe! | 77 bwipe! |
76 set updatetime& updatecount& | 78 set updatetime& updatecount& |
77 endfunc | 79 endfunc |
80 | |
81 " Test signal INT. Handler sets got_int. It should be like typing CTRL-C. | |
82 func Test_signal_INT() | |
83 if !HasSignal('INT') | |
84 throw 'Skipped: INT signal not supported' | |
85 endif | |
86 | |
87 " Skip the rest of the test when running with valgrind as signal INT is not | |
88 " received somehow by Vim when running with valgrind. | |
89 let cmd = GetVimCommand() | |
90 if cmd =~ 'valgrind' | |
91 throw 'Skipped: cannot test signal INT with valgrind' | |
92 endif | |
93 | |
94 if !CanRunVimInTerminal() | |
95 throw 'Skipped: cannot run vim in terminal' | |
96 endif | |
97 let buf = RunVimInTerminal('', {'rows': 6}) | |
98 let pid_vim = term_getjob(buf)->job_info().process | |
99 | |
100 " Check that an endless loop in Vim is interrupted by signal INT. | |
101 call term_sendkeys(buf, ":while 1 | endwhile\n") | |
102 call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))}) | |
103 exe 'silent !kill -s INT ' .. pid_vim | |
104 call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n") | |
105 call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))}) | |
106 | |
107 call StopVimInTerminal(buf) | |
108 endfunc |