annotate src/testdir/test_signals.vim @ 17049:f38fcbf343ce v8.1.1524

patch 8.1.1524: tests are silently skipped commit https://github.com/vim/vim/commit/b0f94c1ff34d27d33aa9f96204985ea29c2eb0a1 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 13 22:19:53 2019 +0200 patch 8.1.1524: tests are silently skipped Problem: Tests are silently skipped. Solution: Throw an exception for skipped tests in more places.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Jun 2019 22:30:07 +0200
parents a0e98821a2ed
children 8e9e9124c7a2
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')
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 16415
diff changeset
4 throw 'Skipped, not on Unix'
16084
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