annotate src/testdir/test_signals.vim @ 28171:b4c111ea83b1 v8.2.4611

patch 8.2.4611: typos in tests; one lua line not covered by test Commit: https://github.com/vim/vim/commit/81b573d7e55bd48988f298ce8e652d902e9bdeba Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Tue Mar 22 21:14:55 2022 +0000 patch 8.2.4611: typos in tests; one lua line not covered by test Problem: Typos in tests; one lua line not covered by test. Solution: Fix typos. Add test case. (Dominique Pell?, closes https://github.com/vim/vim/issues/9994)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Mar 2022 22:30:03 +0100
parents 3c1dcb63f579
children cf881b3169ce
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
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
3 source check.vim
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
4 source term_util.vim
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
5
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
6 CheckUnix
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
8 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
9
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
10 " 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
11 func HasSignal(signal)
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
12 let signals = system('kill -l')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
13 return signals =~# '\<' .. a:signal .. '\>'
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
14 endfunc
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 " Test signal WINCH (window resize signal)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 func Test_signal_WINCH()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
18 CheckNotGui
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
19 if !HasSignal('WINCH')
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
20 throw 'Skipped: WINCH signal not supported'
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 " 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
24 let old_WS = ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 if exists('&t_WS')
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 let old_WS = &t_WS
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 let &t_WS = ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 let old_lines = &lines
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 let old_columns = &columns
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 let new_lines = &lines - 2
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 let new_columns = &columns - 2
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
35 exe 'set lines=' .. new_lines
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
36 exe 'set columns=' .. new_columns
16084
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call assert_equal(new_lines, &lines)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call assert_equal(new_columns, &columns)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " 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
41 " '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
42 " after handing signal WINCH.
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
43 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
44 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
45 call assert_equal(old_columns, &columns)
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 if old_WS != ''
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 let &t_WS = old_WS
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 endif
ed1482db2d72 patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 endfunc
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
51
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
52 " 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
53 func Test_signal_PWR()
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
54 if !HasSignal('PWR')
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
55 throw 'Skipped: PWR signal not supported'
16415
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
56 endif
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
57
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
58 " 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
59 " 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
60 " 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
61 set updatetime=100000 updatecount=100000
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
62 new Xtest_signal_PWR
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
63 let swap_name = swapname('%')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
64 call setline(1, '123')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
65 preserve
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
66 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
67
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
68 " 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
69 " 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
70 call setline(1, 'abc')
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
71 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
72
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
73 " 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
74 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
75 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
76
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
77 bwipe!
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
78 set updatetime& updatecount&
a0e98821a2ed patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16192
diff changeset
79 endfunc
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
80
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
81 " Test signal INT. Handler sets got_int. It should be like typing CTRL-C.
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
82 func Test_signal_INT()
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20429
diff changeset
83 CheckRunVimInTerminal
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
84 if !HasSignal('INT')
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
85 throw 'Skipped: INT signal not supported'
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
86 endif
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
87
23467
826a6406ea7b patch 8.2.2276: list of distributed files is outdated
Bram Moolenaar <Bram@vim.org>
parents: 23108
diff changeset
88 " Skip the test when running with valgrind as signal INT is not received
826a6406ea7b patch 8.2.2276: list of distributed files is outdated
Bram Moolenaar <Bram@vim.org>
parents: 23108
diff changeset
89 " somehow by Vim when running with valgrind.
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
90 let cmd = GetVimCommand()
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
91 if cmd =~ 'valgrind'
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
92 throw 'Skipped: cannot test signal INT with valgrind'
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
93 endif
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
94
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
95 let buf = RunVimInTerminal('', {'rows': 6})
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
96 let pid_vim = term_getjob(buf)->job_info().process
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
97
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
98 " Check that an endless loop in Vim is interrupted by signal INT.
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
99 call term_sendkeys(buf, ":while 1 | endwhile\n")
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
100 call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))})
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
101 exe 'silent !kill -s INT ' .. pid_vim
28171
b4c111ea83b1 patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents: 26825
diff changeset
102 call term_sendkeys(buf, ":call setline(1, 'INTERRUPTED')\n")
b4c111ea83b1 patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents: 26825
diff changeset
103 call WaitForAssert({-> assert_equal('INTERRUPTED', term_getline(buf, 1))})
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
104
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
105 call StopVimInTerminal(buf)
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
106 endfunc
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
107
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
108 " Test signal TSTP. Handler sets got_tstp.
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
109 func Test_signal_TSTP()
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
110 CheckRunVimInTerminal
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
111 if !HasSignal('TSTP')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
112 throw 'Skipped: TSTP signal not supported'
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
113 endif
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
114
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
115 " Skip the test when running with valgrind as signal TSTP is not received
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
116 " somehow by Vim when running with valgrind.
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
117 let cmd = GetVimCommand()
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
118 if cmd =~ 'valgrind'
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
119 throw 'Skipped: cannot test signal TSTP with valgrind'
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
120 endif
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
121
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
122 " If test fails once, it can leave temporary files and trying to rerun
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
123 " the test would then fail again if they are not deleted first.
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
124 call delete('.Xsig_TERM.swp')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
125 call delete('XsetupAucmd')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
126 call delete('XautoOut')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
127 let lines =<< trim END
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
128 au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut", "as")
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
129 au VimResume * call writefile(["VimResume triggered"], "XautoOut", "as")
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
130 END
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
131 call writefile(lines, 'XsetupAucmd')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
132
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
133 let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
134 let pid_vim = term_getjob(buf)->job_info().process
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
135
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
136 call term_sendkeys(buf, ":call setline(1, 'foo')\n")
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
137 call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))})
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
138
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
139 call assert_false(filereadable('Xsig_TERM'))
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
140
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
141 " After TSTP the file is not saved (same function as ^Z)
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
142 exe 'silent !kill -s TSTP ' .. pid_vim
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
143 call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
144
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
145 " We resume after the suspend
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
146 exe 'silent !kill -s CONT ' .. pid_vim
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
147 exe 'silent !sleep 0.006'
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
148
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
149 call StopVimInTerminal(buf)
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
150
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
151 let result = readfile('XautoOut')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
152 call assert_equal(["VimSuspend triggered", "VimResume triggered"], result)
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
153
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
154 %bwipe!
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
155 call delete('.Xsig_TERM.swp')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
156 call delete('XsetupAucmd')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
157 call delete('XautoOut')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
158 endfunc
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
159
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
160 " Test a deadly signal.
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
161 "
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
162 " There are several deadly signals: SISEGV, SIBUS, SIGTERM...
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
163 " Test uses signal SIGTERM as it does not create a core
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
164 " dump file unlike SIGSEGV, SIGBUS, etc. See "man 7 signals.
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
165 "
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
166 " Vim should exit with a deadly signal and unsaved changes
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
167 " should be recoverable from the swap file preserved as a
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
168 " result of the deadly signal handler.
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
169 func Test_deadly_signal_TERM()
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
170 if !HasSignal('TERM')
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
171 throw 'Skipped: TERM signal not supported'
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
172 endif
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20429
diff changeset
173 CheckRunVimInTerminal
20641
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
174
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
175 " If test fails once, it can leave temporary files and trying to rerun
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
176 " the test would then fail again if they are not deleted first.
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
177 call delete('.Xsig_TERM.swp')
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
178 call delete('XsetupAucmd')
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
179 call delete('XautoOut')
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
180 let lines =<< trim END
20641
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
181 au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "as")
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
182 au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "as")
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
183 END
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
184 call writefile(lines, 'XsetupAucmd')
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
185
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
186 let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
187 let pid_vim = term_getjob(buf)->job_info().process
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
188
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
189 call term_sendkeys(buf, ":call setline(1, 'foo')\n")
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
190 call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))})
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
191
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
192 call assert_false(filereadable('Xsig_TERM'))
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
193 exe 'silent !kill -s TERM ' .. pid_vim
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
194 call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
195
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
196 " Don't call StopVimInTerminal() as it expects job to be still running.
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
197 call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
198
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
199 new
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
200 silent recover .Xsig_TERM.swp
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
201 call assert_equal(['foo'], getline(1, '$'))
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
202
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
203 let result = readfile('XautoOut')
23108
34a74f5f0fb4 patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents: 20641
diff changeset
204 call assert_equal(["VimLeavePre triggered", "VimLeave triggered"], result)
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
205
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
206 %bwipe!
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
207 call delete('.Xsig_TERM.swp')
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
208 call delete('XsetupAucmd')
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
209 call delete('XautoOut')
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
210 endfunc
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
211
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
212 " vim: ts=8 sw=2 sts=2 tw=80 fdm=marker