aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-22 00:00:23 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-22 18:08:35 -0500
commit0914faf7fac75bed7e7b48c6e24fd3b585c6c05d (patch)
tree765b06129920098691885434fbd6bc342c47a30e
parent7e63bbe4ecd3c552c984f0499576db8f7c291d08 (diff)
downloadrneovim-0914faf7fac75bed7e7b48c6e24fd3b585c6c05d.tar.gz
rneovim-0914faf7fac75bed7e7b48c6e24fd3b585c6c05d.tar.bz2
rneovim-0914faf7fac75bed7e7b48c6e24fd3b585c6c05d.zip
vim-patch:8.1.1212: signal PWR is not tested
Problem: Signal PWR is not tested. Solution: Test that PWR updates the swap file. (Dominique Pelle, closes vim/vim#4312) https://github.com/vim/vim/commit/520e245237fa92f9022968a52eb418da6eade9b4
-rw-r--r--src/nvim/testdir/test_signals.vim50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim
index 79cbea3e7d..0e15bde554 100644
--- a/src/nvim/testdir/test_signals.vim
+++ b/src/nvim/testdir/test_signals.vim
@@ -4,19 +4,18 @@ if !has('unix')
finish
endif
-if has('gui_running')
- " Signals only work for terminals, and won't work for GUI.
- finish
-endif
-
source shared.vim
+" Check whether a signal is available on this system.
+func HasSignal(signal)
+ let signals = system('kill -l')
+ return signals =~# '\<' .. a:signal .. '\>'
+endfunc
+
" Test signal WINCH (window resize signal)
func Test_signal_WINCH()
throw 'skipped: Nvim cannot avoid terminal resize'
- let signals = system('kill -l')
- if signals !~ '\<WINCH\>'
- " signal WINCH is not available, skip the test.
+ if has('gui_running') || !HasSignal('WINCH')
return
endif
@@ -32,15 +31,15 @@ func Test_signal_WINCH()
let new_lines = &lines - 2
let new_columns = &columns - 2
- exe 'set lines=' . new_lines
- exe 'set columns=' . new_columns
+ exe 'set lines=' .. new_lines
+ exe 'set columns=' .. new_columns
call assert_equal(new_lines, &lines)
call assert_equal(new_columns, &columns)
" Send signal and wait for signal to be processed.
" 'lines' and 'columns' should have been restored
" after handing signal WINCH.
- exe 'silent !kill -s WINCH ' . getpid()
+ exe 'silent !kill -s WINCH ' .. getpid()
call WaitForAssert({-> assert_equal(old_lines, &lines)})
call assert_equal(old_columns, &columns)
@@ -48,3 +47,32 @@ func Test_signal_WINCH()
let &t_WS = old_WS
endif
endfunc
+
+" Test signal PWR, which should update the swap file.
+func Test_signal_PWR()
+ if !HasSignal('PWR')
+ return
+ endif
+
+ " Set a very large 'updatetime' and 'updatecount', so that we can be sure
+ " that swap file is updated as a result of sending PWR signal, and not
+ " because of exceeding 'updatetime' or 'updatecount' when changing buffer.
+ set updatetime=100000 updatecount=100000
+ new Xtest_signal_PWR
+ let swap_name = swapname('%')
+ call setline(1, '123')
+ preserve
+ let swap_content = readfile(swap_name, 'b')
+
+ " Update the buffer and check that the swap file is not yet updated,
+ " since we set 'updatetime' and 'updatecount' to large values.
+ call setline(1, 'abc')
+ call assert_equal(swap_content, readfile(swap_name, 'b'))
+
+ " Sending PWR signal should update the swap file.
+ exe 'silent !kill -s PWR ' .. getpid()
+ call WaitForAssert({-> assert_notequal(swap_content, readfile(swap_name, 'b'))})
+
+ bwipe!
+ set updatetime& updatecount&
+endfunc