Mercurial > vim
annotate src/testdir/test_signals.vim @ 26018:c2d4e40a32a6 v8.2.3543
patch 8.2.3543: swapname has double slash when 'directory' ends in it
Commit: https://github.com/vim/vim/commit/8b0e62c93b6dad5ec5b2c7558d4f7b78c46216d2
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 19 22:12:25 2021 +0100
patch 8.2.3543: swapname has double slash when 'directory' ends in it
Problem: Swapname has double slash when 'directory' ends in double slash.
(Shane Smith)
Solution: Remove the superfluous slash. (closes #8876)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 19 Oct 2021 23:15:03 +0200 |
parents | 826a6406ea7b |
children | 3c1dcb63f579 |
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 |
c9cc9e5c87e0
patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
102 call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n") |
c9cc9e5c87e0
patch 8.2.0433: INT signal not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
103 call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))}) |
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 |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
108 " 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
|
109 " |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
110 " 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
|
111 " 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
|
112 " 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
|
113 " |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
114 " 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
|
115 " 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
|
116 " 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
|
117 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
|
118 if !HasSignal('TERM') |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
119 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
|
120 endif |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20429
diff
changeset
|
121 CheckRunVimInTerminal |
20641
20b6d5304e56
patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
122 |
20b6d5304e56
patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
123 " 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
|
124 " 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
|
125 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
|
126 call delete('XsetupAucmd') |
20b6d5304e56
patch 8.2.0874: signals test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 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
|
131 END |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20388
diff
changeset
|
132 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
|
133 |
20429
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20388
diff
changeset
|
134 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
|
135 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
|
136 |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
137 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
|
138 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
|
139 |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
144 " 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
|
145 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
|
146 |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
147 new |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
148 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
|
149 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
|
150 |
20429
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20388
diff
changeset
|
151 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
|
152 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
|
153 |
20373
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
154 %bwipe! |
f8835e16c34e
patch 8.2.0742: handling of a TERM signal not tested
Bram Moolenaar <Bram@vim.org>
parents:
19754
diff
changeset
|
155 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
|
156 call delete('XsetupAucmd') |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20388
diff
changeset
|
157 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
|
158 endfunc |
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: ts=8 sw=2 sts=2 tw=80 fdm=marker |