blob: af7b88201adf47e014555d2a9cb96d0d0de577ee [file] [log] [blame]
Bram Moolenaardb77b842019-03-24 14:58:31 +01001" Test signal handling.
2
3if !has('unix')
4 finish
5endif
6
Bram Moolenaar690a9052019-04-02 21:45:41 +02007if has('gui_running')
8 " Signals only work for terminals, and won't work for GUI.
9 finish
10endif
11
Bram Moolenaardb77b842019-03-24 14:58:31 +010012source shared.vim
13
14" Test signal WINCH (window resize signal)
15func Test_signal_WINCH()
16 let signals = system('kill -l')
17 if signals !~ '\<WINCH\>'
18 " signal WINCH is not available, skip the test.
19 return
20 endif
21
22 " We do not actually want to change the size of the terminal.
23 let old_WS = ''
24 if exists('&t_WS')
25 let old_WS = &t_WS
26 let &t_WS = ''
27 endif
28
29 let old_lines = &lines
30 let old_columns = &columns
31 let new_lines = &lines - 2
32 let new_columns = &columns - 2
33
34 exe 'set lines=' . new_lines
35 exe 'set columns=' . new_columns
36 call assert_equal(new_lines, &lines)
37 call assert_equal(new_columns, &columns)
38
39 " Send signal and wait for signal to be processed.
40 " 'lines' and 'columns' should have been restored
41 " after handing signal WINCH.
42 exe 'silent !kill -s WINCH ' . getpid()
43 call WaitForAssert({-> assert_equal(old_lines, &lines)})
44 call assert_equal(old_columns, &columns)
45
46 if old_WS != ''
47 let &t_WS = old_WS
48 endif
49endfunc