annotate src/testdir/test_signals.vim @ 16663:66ffbbee468c

Added tag v8.1.1333 for changeset 1fc9cd08cf3c29190ce143ff1e370e7ebfb9dff6
author Bram Moolenaar <Bram@vim.org>
date Wed, 15 May 2019 23:00:18 +0200
parents a0e98821a2ed
children f38fcbf343ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test signal handling.
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 if !has('unix')
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 finish
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
7 source shared.vim
16192
1ab0d1f7807a patch 8.1.1101: signals test may fail in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 16084
diff changeset
8
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
9 " Check whether a signal is available on this system.
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
10 func HasSignal(signal)
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
11 let signals = system('kill -l')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
12 return signals =~# '\<' .. a:signal .. '\>'
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
13 endfunc
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 " Test signal WINCH (window resize signal)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 func Test_signal_WINCH()
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
17 if has('gui_running') || !HasSignal('WINCH')
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 return
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 " We do not actually want to change the size of the terminal.
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 let old_WS = ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 if exists('&t_WS')
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 let old_WS = &t_WS
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 let &t_WS = ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 let old_lines = &lines
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 let old_columns = &columns
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 let new_lines = &lines - 2
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 let new_columns = &columns - 2
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
33 exe 'set lines=' .. new_lines
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
34 exe 'set columns=' .. new_columns
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_equal(new_lines, &lines)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call assert_equal(new_columns, &columns)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 " Send signal and wait for signal to be processed.
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 " 'lines' and 'columns' should have been restored
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " after handing signal WINCH.
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
41 exe 'silent !kill -s WINCH ' .. getpid()
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 call WaitForAssert({-> assert_equal(old_lines, &lines)})
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 call assert_equal(old_columns, &columns)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 if old_WS != ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 let &t_WS = old_WS
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 endfunc
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
49
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
50 " Test signal PWR, which should update the swap file.
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
51 func Test_signal_PWR()
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
52 if !HasSignal('PWR')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
53 return
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
54 endif
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
55
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
56 " Set a very large 'updatetime' and 'updatecount', so that we can be sure
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
57 " that swap file is updated as a result of sending PWR signal, and not
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
58 " because of exceeding 'updatetime' or 'updatecount' when changing buffer.
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
59 set updatetime=100000 updatecount=100000
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
60 new Xtest_signal_PWR
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
61 let swap_name = swapname('%')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
62 call setline(1, '123')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
63 preserve
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
64 let swap_content = readfile(swap_name, 'b')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
65
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
66 " Update the buffer and check that the swap file is not yet updated,
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
67 " since we set 'updatetime' and 'updatecount' to large values.
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
68 call setline(1, 'abc')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
69 call assert_equal(swap_content, readfile(swap_name, 'b'))
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
70
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
71 " Sending PWR signal should update the swap file.
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
72 exe 'silent !kill -s PWR ' .. getpid()
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
73 call WaitForAssert({-> assert_notequal(swap_content, readfile(swap_name, 'b'))})
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
74
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
75 bwipe!
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
76 set updatetime& updatecount&
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
77 endfunc