annotate src/testdir/test_signals.vim @ 32764:d35204b890af v9.0.1701

patch 9.0.1701: vim9 crash when class member overridden Commit: https://github.com/vim/vim/commit/57a02ccf4c75a6abb270194c90be926d5221b3ce Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Aug 13 10:19:38 2023 +0200 patch 9.0.1701: vim9 crash when class member overridden Problem: vim9 crash when class member overridden Solution: Use method_count field instead closes: #12676 closes: #12677 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 13 Aug 2023 10:30:07 +0200
parents dbec60b8c253
children
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
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
88 let buf = RunVimInTerminal('', {'rows': 6})
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
89 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
90
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
91 " Check that an endless loop in Vim is interrupted by signal INT.
29281
cf881b3169ce patch 8.2.5158: TSTP and INT signal tests are not run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
92 call term_sendkeys(buf, ":call setline(1, 'running')\n")
19754
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
93 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
94 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
95 exe 'silent !kill -s INT ' .. pid_vim
29281
cf881b3169ce patch 8.2.5158: TSTP and INT signal tests are not run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
96 sleep 50m
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
97 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
98 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
99
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
100 call StopVimInTerminal(buf)
c9cc9e5c87e0 patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
101 endfunc
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
102
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
103 " 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
104 func Test_signal_TSTP()
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
105 CheckRunVimInTerminal
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
106 if !HasSignal('TSTP')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
107 throw 'Skipped: TSTP signal not supported'
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
108 endif
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
109
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
110 " 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
111 " 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
112 call delete('.Xsig_TERM.swp')
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
113 call delete('XsetupAucmd')
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
114 call delete('XautoOut1')
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
115 call delete('XautoOut2')
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
116 let lines =<< trim END
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
117 au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut1", "as")
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
118 au VimResume * call writefile(["VimResume triggered"], "XautoOut2", "as")
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
119 END
30769
ae10b91ac6b3 patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30114
diff changeset
120 call writefile(lines, 'XsetupAucmd', 'D')
26825
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 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
123 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
124
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
125 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
126 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
127
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
128 call assert_false(filereadable('Xsig_TERM'))
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
129
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
130 " 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
131 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
132 call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
133 sleep 100m
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
134
29281
cf881b3169ce patch 8.2.5158: TSTP and INT signal tests are not run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
135 " We resume after the suspend. Sleep a bit for the signal to take effect,
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
136 " also when running under valgrind.
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
137 exe 'silent !kill -s CONT ' .. pid_vim
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
138 call WaitForAssert({-> assert_true(filereadable('XautoOut2'))})
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
139 sleep 10m
26825
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 call StopVimInTerminal(buf)
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
142
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
143 let result = readfile('XautoOut1')
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
144 call assert_equal(["VimSuspend triggered"], result)
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
145 let result = readfile('XautoOut2')
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
146 call assert_equal(["VimResume triggered"], result)
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
147
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
148 %bwipe!
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
149 call delete('.Xsig_TERM.swp')
30114
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
150 call delete('XautoOut1')
eae1e99e66de patch 9.0.0393: signals test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 29281
diff changeset
151 call delete('XautoOut2')
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
152 endfunc
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
153
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
154 " 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
155 "
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
156 " 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
157 " 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
158 " 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
159 "
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
160 " 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
161 " 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
162 " 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
163 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
164 if !HasSignal('TERM')
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
165 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
166 endif
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20429
diff changeset
167 CheckRunVimInTerminal
20641
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
168
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
169 " 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
170 " 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
171 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
172 call delete('XsetupAucmd')
20b6d5304e56 patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
173 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
174 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
175 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
176 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
177 END
30769
ae10b91ac6b3 patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30114
diff changeset
178 call writefile(lines, 'XsetupAucmd', 'D')
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
179
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
180 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
181 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
182
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
183 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
184 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
185
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
186 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
187 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
188 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
189
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
190 " 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
191 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
192
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
193 new
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
194 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
195 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
196
20429
c88ebfcbab03 patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents: 20388
diff changeset
197 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
198 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
199
20373
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
200 %bwipe!
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
201 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
202 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
203 endfunc
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
204
f8835e16c34e patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents: 19754
diff changeset
205 " vim: ts=8 sw=2 sts=2 tw=80 fdm=marker