Mercurial > vim
annotate src/testdir/test_signals.vim @ 18049:a9f1656f13c9 v8.1.2020
patch 8.1.2020: it is not easy to change the window layout
Commit: https://github.com/vim/vim/commit/d20dcb3d011da6111153109f6e46fbd5c7fe9fb6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 10 21:22:58 2019 +0200
patch 8.1.2020: it is not easy to change the window layout
Problem: It is not easy to change the window layout.
Solution: Add win_splitmove(). (Andy Massimino, closes https://github.com/vim/vim/issues/4561)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 10 Sep 2019 21:30:05 +0200 |
parents | 0da9bc55c31a |
children | c9cc9e5c87e0 |
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 |
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
4 CheckUnix |
16084
ed1482db2d72
patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 |
16415
a0e98821a2ed
patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16192
diff
changeset
|
6 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
|
7 |
16415
a0e98821a2ed
patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16192
diff
changeset
|
8 " 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
|
9 func HasSignal(signal) |
a0e98821a2ed
patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16192
diff
changeset
|
10 let signals = system('kill -l') |
a0e98821a2ed
patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16192
diff
changeset
|
11 return signals =~# '\<' .. a:signal .. '\>' |
a0e98821a2ed
patch 8.1.1212: signal PWR is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16192
diff
changeset
|
12 endfunc |
16084
ed1482db2d72
patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
ed1482db2d72
patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 " Test signal WINCH (window resize signal) |
ed1482db2d72
patch 8.1.1047: WINCH signal is not tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 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
|
16 CheckNotGui |
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
17 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
|
18 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
|
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 |