Bram Moolenaar | db77b84 | 2019-03-24 14:58:31 +0100 | [diff] [blame] | 1 | " Test signal handling. |
| 2 | |
| 3 | if !has('unix') |
| 4 | finish |
| 5 | endif |
| 6 | |
Bram Moolenaar | 690a905 | 2019-04-02 21:45:41 +0200 | [diff] [blame] | 7 | if has('gui_running') |
| 8 | " Signals only work for terminals, and won't work for GUI. |
| 9 | finish |
| 10 | endif |
| 11 | |
Bram Moolenaar | db77b84 | 2019-03-24 14:58:31 +0100 | [diff] [blame] | 12 | source shared.vim |
| 13 | |
| 14 | " Test signal WINCH (window resize signal) |
| 15 | func 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 |
| 49 | endfunc |