From 2b781a6d7f0bda56b9c5491724fabc38a19ca545 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 21 Dec 2020 23:56:10 -0500 Subject: vim-patch:8.1.1047: WINCH signal is not tested Problem: WINCH signal is not tested. Solution: Add a test. (Dominique Pelle, closes vim/vim#4158) https://github.com/vim/vim/commit/db77b84ac2b6373ae4200d47945fc6ca64337e31 --- src/nvim/testdir/test_signals.vim | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/nvim/testdir/test_signals.vim (limited to 'src') diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim new file mode 100644 index 0000000000..cdea278fa0 --- /dev/null +++ b/src/nvim/testdir/test_signals.vim @@ -0,0 +1,45 @@ +" Test signal handling. + +if !has('unix') + finish +endif + +source shared.vim + +" Test signal WINCH (window resize signal) +func Test_signal_WINCH() + throw 'skipped: Nvim cannot avoid terminal resize' + let signals = system('kill -l') + if signals !~ '\' + " signal WINCH is not available, skip the test. + return + endif + + " We do not actually want to change the size of the terminal. + let old_WS = '' + if exists('&t_WS') + let old_WS = &t_WS + let &t_WS = '' + endif + + let old_lines = &lines + let old_columns = &columns + let new_lines = &lines - 2 + let new_columns = &columns - 2 + + 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() + call WaitForAssert({-> assert_equal(old_lines, &lines)}) + call assert_equal(old_columns, &columns) + + if old_WS != '' + let &t_WS = old_WS + endif +endfunc -- cgit From 7e63bbe4ecd3c552c984f0499576db8f7c291d08 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 21 Dec 2020 23:59:58 -0500 Subject: vim-patch:8.1.1101: signals test may fail in the GUI Problem: Signals test may fail in the GUI. Solution: Skip the test for the GUI. (Yee Checng Chin, closes vim/vim#4202) https://github.com/vim/vim/commit/690a905a0199f5ff733e5a12be9ba94ae6043ef4 --- src/nvim/testdir/test_signals.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim index cdea278fa0..79cbea3e7d 100644 --- a/src/nvim/testdir/test_signals.vim +++ b/src/nvim/testdir/test_signals.vim @@ -4,6 +4,11 @@ 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 " Test signal WINCH (window resize signal) -- cgit From 0914faf7fac75bed7e7b48c6e24fd3b585c6c05d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 00:00:23 -0500 Subject: 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 --- src/nvim/testdir/test_signals.vim | 50 ++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'src') 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 !~ '\' - " 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 -- cgit From 8355ea25880b4e425917d5ac109f0f293a971ee1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 00:14:05 -0500 Subject: vim-patch:8.2.0742: handling of a TERM signal not tested Problem: Handling of a TERM signal not tested. Solution: Add a test for SIGTERM. (Dominique Pelle, closes vim/vim#6055) https://github.com/vim/vim/commit/48a687148c4649f6f55b36a1f4111041e7207235 --- src/nvim/testdir/test_signals.vim | 53 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim index 0e15bde554..830abcf1f5 100644 --- a/src/nvim/testdir/test_signals.vim +++ b/src/nvim/testdir/test_signals.vim @@ -1,8 +1,9 @@ " Test signal handling. -if !has('unix') - finish -endif +source check.vim +source term_util.vim + +CheckUnix source shared.vim @@ -76,3 +77,49 @@ func Test_signal_PWR() bwipe! set updatetime& updatecount& endfunc + +" Test a deadly signal. +" +" There are several deadly signals: SISEGV, SIBUS, SIGTERM... +" Test uses signal SIGTERM as it does not create a core +" dump file unlike SIGSEGV, SIGBUS, etc. See "man 7 signals. +" +" Vim should exit with a deadly signal and unsaved changes +" should be recoverable from the swap file preserved as a +" result of the deadly signal handler. +func Test_deadly_signal_TERM() + if !HasSignal('TERM') + throw 'Skipped: TERM signal not supported' + endif + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let cmd = GetVimCommand() + if cmd =~ 'valgrind' + throw 'Skipped: cannot test signal TERM with valgrind' + endif + + let buf = RunVimInTerminal('Xsig_TERM', {'rows': 6}) + let pid_vim = term_getjob(buf)->job_info().process + + call term_sendkeys(buf, ":call setline(1, 'foo')\n") + call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))}) + + call assert_false(filereadable('Xsig_TERM')) + exe 'silent !kill -s TERM ' .. pid_vim + call WaitForAssert({-> assert_equal('Vim: Caught deadly signal TERM', term_getline(buf, 1))}) + call WaitForAssert({-> assert_match('Vim: preserving files\.\.\.$', term_getline(buf, 2))}) + call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))}) + + " Don't call StopVimInTerminal() as it expects job to be still running. + call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) + + new + silent recover .Xsig_TERM.swp + call assert_equal(['foo'], getline(1, '$')) + + %bwipe! + call delete('.Xsig_TERM.swp') +endfunc + +" vim: ts=8 sw=2 sts=2 tw=80 fdm=marker -- cgit From 40f9b1dd2cd843a001d7df90647706704f240eb5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 00:14:52 -0500 Subject: vim-patch:8.2.0749: TERM signal test fails on FreeBSD Problem: TERM signal test fails on FreeBSD. Solution: Do not check the messages, the may appear anywhere. (Dominique Pelle, closes vim/vim#6075) https://github.com/vim/vim/commit/55ba4b844f1b0e44f0f2e1bd14d26e7ad2df9ffc --- src/nvim/testdir/test_signals.vim | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim index 830abcf1f5..fdcb37a6d9 100644 --- a/src/nvim/testdir/test_signals.vim +++ b/src/nvim/testdir/test_signals.vim @@ -107,8 +107,6 @@ func Test_deadly_signal_TERM() call assert_false(filereadable('Xsig_TERM')) exe 'silent !kill -s TERM ' .. pid_vim - call WaitForAssert({-> assert_equal('Vim: Caught deadly signal TERM', term_getline(buf, 1))}) - call WaitForAssert({-> assert_match('Vim: preserving files\.\.\.$', term_getline(buf, 2))}) call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))}) " Don't call StopVimInTerminal() as it expects job to be still running. -- cgit From caf2620f18affec2846b56de4f6bf6453296537a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 00:15:18 -0500 Subject: vim-patch:8.2.0769: VimLeavePre not triggered when Vim is terminated Problem: VimLeavePre not triggered when Vim is terminated. Solution: Unblock autocommands. https://github.com/vim/vim/commit/129d6bf6b3d120b0a4c69e18b5e8602a84e352bf --- src/nvim/main.c | 13 ++++++++++++- src/nvim/testdir/test_signals.vim | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index ed055e76ba..41ae78e996 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -653,7 +653,18 @@ void getout(int exitval) } } } - apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); + + int unblock = 0; + // deathtrap() blocks autocommands, but we do want to trigger + // VimLeavePre. + if (is_autocmd_blocked()) { + unblock_autocmds(); + unblock++; + } + apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, false, curbuf); + if (unblock) { + block_autocmds(); + } } if (p_shada && *p_shada != NUL) { diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim index fdcb37a6d9..fab42cb7c6 100644 --- a/src/nvim/testdir/test_signals.vim +++ b/src/nvim/testdir/test_signals.vim @@ -98,8 +98,13 @@ func Test_deadly_signal_TERM() if cmd =~ 'valgrind' throw 'Skipped: cannot test signal TERM with valgrind' endif + let lines =<< trim END + au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "a") + au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "a") + END + call writefile(lines, 'XsetupAucmd') - let buf = RunVimInTerminal('Xsig_TERM', {'rows': 6}) + let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6}) let pid_vim = term_getjob(buf)->job_info().process call term_sendkeys(buf, ":call setline(1, 'foo')\n") @@ -116,8 +121,14 @@ func Test_deadly_signal_TERM() silent recover .Xsig_TERM.swp call assert_equal(['foo'], getline(1, '$')) + let result = readfile('XautoOut') + call assert_match('VimLeavePre triggered', result[0]) + call assert_match('VimLeave triggered', result[1]) + %bwipe! call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') endfunc " vim: ts=8 sw=2 sts=2 tw=80 fdm=marker -- cgit From dd515b70979c70e2461a6f1a16bc9fc5582a7521 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 00:31:40 -0500 Subject: vim-patch:8.2.0874: signals test is a bit flaky Problem: Signals test is a bit flaky. Solution: Flush the XautoOut file. Delete files that may be left behind from a failure. (Dominique Pelle, closes vim/vim#6179) https://github.com/vim/vim/commit/d14fd5285e491a39028c4b4722ddbe7c9dfa9bb2 --- src/nvim/testdir/test_signals.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim index fab42cb7c6..338c0d79ff 100644 --- a/src/nvim/testdir/test_signals.vim +++ b/src/nvim/testdir/test_signals.vim @@ -98,9 +98,15 @@ func Test_deadly_signal_TERM() if cmd =~ 'valgrind' throw 'Skipped: cannot test signal TERM with valgrind' endif + + " If test fails once, it can leave temporary files and trying to rerun + " the test would then fail again if they are not deleted first. + call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') let lines =<< trim END - au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "a") - au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "a") + au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "as") + au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "as") END call writefile(lines, 'XsetupAucmd') -- cgit From 0561243771592b9d00a32fb7151592dd507c4709 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 01:01:10 -0500 Subject: vim-patch:8.2.2142: memory leak when heredoc is not terminated Problem: Memory leak when heredoc is not terminated. Solution: Free heredoc_trimmed. https://github.com/vim/vim/commit/fffdf4754f4fd789c64596bdd9ea069725e63784 --- src/nvim/eval/userfunc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8daef00985..4e8b98d723 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2484,6 +2484,7 @@ errret_2: ga_clear_strings(&newlines); ret_free: xfree(skip_until); + xfree(heredoc_trimmed); xfree(line_to_free); xfree(fudi.fd_newkey); xfree(name); -- cgit From b602fe74b075b5e3c4f095d907bed9abc98462f3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 22 Dec 2020 18:11:59 -0500 Subject: vim-patch:8.2.2189: cannot repeat a command that uses the small delete register Problem: Cannot repeat a command that uses the small delete register. Solution: Store the register name instead of the contents. (Christian Brabandt, closes vim/vim#7527) https://github.com/vim/vim/commit/032a2d050b82b146d70d6ff714838ee62c07d8ad N/A patches for version.c: vim-patch:8.2.2192: Codecov on github actions fails Problem: Codecov on github actions fails. Solution: Revert to codecov script. (Ozaki Kiichi, closes vim/vim#7529) https://github.com/vim/vim/commit/e5492609b3a153c631f1d600ecdef1af1c913bef --- src/nvim/ops.c | 8 +++++++- src/nvim/testdir/test_registers.vim | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 37db1bb7e2..8fddb1b561 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1197,7 +1197,13 @@ int insert_reg( retval = FAIL; } else { for (size_t i = 0; i < reg->y_size; i++) { - stuffescaped((const char *)reg->y_array[i], literally); + if (regname == '-') { + AppendCharToRedobuff(Ctrl_R); + AppendCharToRedobuff(regname); + do_put(regname, NULL, BACKWARD, 1L, PUT_CURSEND); + } else { + stuffescaped((const char *)reg->y_array[i], literally); + } // Insert a newline between lines and after last line if // y_type is kMTLineWise. if (reg->y_type == kMTLineWise || i < reg->y_size - 1) { diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index 19a7c6c9d0..24e02cb385 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -254,4 +254,15 @@ func Test_ve_blockpaste() bwipe! endfunc +func Test_insert_small_delete() + new + call setline(1, ['foo foobar bar']) + call cursor(1,1) + exe ":norm! ciw'\-'" + call assert_equal(getline(1), "'foo' foobar bar") + exe ":norm! w.w." + call assert_equal(getline(1), "'foo' 'foobar' 'bar'") + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit