mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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 #4312)
This commit is contained in:
parent
e61e548dd6
commit
520e245237
@ -4,18 +4,17 @@ if !has('unix')
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('gui_running')
|
|
||||||
" Signals only work for terminals, and won't work for GUI.
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
source shared.vim
|
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)
|
" Test signal WINCH (window resize signal)
|
||||||
func Test_signal_WINCH()
|
func Test_signal_WINCH()
|
||||||
let signals = system('kill -l')
|
if has('gui_running') || !HasSignal('WINCH')
|
||||||
if signals !~ '\<WINCH\>'
|
|
||||||
" signal WINCH is not available, skip the test.
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -31,15 +30,15 @@ func Test_signal_WINCH()
|
|||||||
let new_lines = &lines - 2
|
let new_lines = &lines - 2
|
||||||
let new_columns = &columns - 2
|
let new_columns = &columns - 2
|
||||||
|
|
||||||
exe 'set lines=' . new_lines
|
exe 'set lines=' .. new_lines
|
||||||
exe 'set columns=' . new_columns
|
exe 'set columns=' .. new_columns
|
||||||
call assert_equal(new_lines, &lines)
|
call assert_equal(new_lines, &lines)
|
||||||
call assert_equal(new_columns, &columns)
|
call assert_equal(new_columns, &columns)
|
||||||
|
|
||||||
" Send signal and wait for signal to be processed.
|
" Send signal and wait for signal to be processed.
|
||||||
" 'lines' and 'columns' should have been restored
|
" 'lines' and 'columns' should have been restored
|
||||||
" after handing signal WINCH.
|
" after handing signal WINCH.
|
||||||
exe 'silent !kill -s WINCH ' . getpid()
|
exe 'silent !kill -s WINCH ' .. getpid()
|
||||||
call WaitForAssert({-> assert_equal(old_lines, &lines)})
|
call WaitForAssert({-> assert_equal(old_lines, &lines)})
|
||||||
call assert_equal(old_columns, &columns)
|
call assert_equal(old_columns, &columns)
|
||||||
|
|
||||||
@ -47,3 +46,32 @@ func Test_signal_WINCH()
|
|||||||
let &t_WS = old_WS
|
let &t_WS = old_WS
|
||||||
endif
|
endif
|
||||||
endfunc
|
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
|
||||||
|
@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1212,
|
||||||
/**/
|
/**/
|
||||||
1211,
|
1211,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user