Patch 8.2.1919
Problem: Assert_fails() setting emsg_silent changes normal execution.
Solution: Use a separate flag in_assert_fails.
Files: src/testing.c, src/globals.h, src/buffer.c, src/change.c,
src/fileio.c, src/insexpand.c, src/message.c, src/misc1.c,
src/normal.c, src/screen.c, src/term.c, src/vim9execute.c,
src/testdir/test_vim9_func.vim, src/testdir/gen_opt_test.vim,
src/testdir/test_autocmd.vim, src/testdir/test_mapping.vim,
src/testdir/test_popup.vim, src/testdir/test_terminal.vim
*** ../vim-8.2.1918/src/testing.c 2020-09-10 19:25:01.612194701 +0200
--- src/testing.c 2020-10-28 19:27:49.976753869 +0100
***************
*** 555,562 ****
// trylevel must be zero for a ":throw" command to be considered failed
trylevel = 0;
suppress_errthrow = TRUE;
! emsg_silent = TRUE;
! emsg_assert_fails_used = TRUE;
do_cmdline_cmd(cmd);
if (called_emsg == called_emsg_before)
--- 555,561 ----
// trylevel must be zero for a ":throw" command to be considered failed
trylevel = 0;
suppress_errthrow = TRUE;
! in_assert_fails = TRUE;
do_cmdline_cmd(cmd);
if (called_emsg == called_emsg_before)
***************
*** 679,687 ****
theend:
trylevel = save_trylevel;
suppress_errthrow = FALSE;
! emsg_silent = FALSE;
emsg_on_display = FALSE;
! emsg_assert_fails_used = FALSE;
VIM_CLEAR(emsg_assert_fails_msg);
set_vim_var_string(VV_ERRMSG, NULL, 0);
if (wrong_arg_msg != NULL)
--- 678,690 ----
theend:
trylevel = save_trylevel;
suppress_errthrow = FALSE;
! in_assert_fails = FALSE;
! did_emsg = FALSE;
! msg_col = 0;
! need_wait_return = FALSE;
emsg_on_display = FALSE;
! msg_scrolled = 0;
! lines_left = Rows;
VIM_CLEAR(emsg_assert_fails_msg);
set_vim_var_string(VV_ERRMSG, NULL, 0);
if (wrong_arg_msg != NULL)
*** ../vim-8.2.1918/src/globals.h 2020-10-12 22:07:09.635378856 +0200
--- src/globals.h 2020-10-28 19:05:31.876679995 +0100
***************
*** 221,227 ****
EXTERN int emsg_severe INIT(= FALSE); // use message of next of several
// emsg() calls for throw
// used by assert_fails()
- EXTERN int emsg_assert_fails_used INIT(= FALSE);
EXTERN char_u *emsg_assert_fails_msg INIT(= NULL);
EXTERN long emsg_assert_fails_lnum INIT(= 0);
EXTERN char_u *emsg_assert_fails_context INIT(= NULL);
--- 221,226 ----
***************
*** 1130,1135 ****
--- 1129,1136 ----
EXTERN int emsg_noredir INIT(= 0); // don't redirect error messages
EXTERN int cmd_silent INIT(= FALSE); // don't echo the command line
+ EXTERN int in_assert_fails INIT(= FALSE); // assert_fails() active
+
EXTERN int swap_exists_action INIT(= SEA_NONE);
// For dialog when swap file already
// exists.
*** ../vim-8.2.1918/src/buffer.c 2020-10-26 21:05:23.905469139 +0100
--- src/buffer.c 2020-10-28 18:23:29.199754471 +0100
***************
*** 2154,2160 ****
if (top_file_num < 0) // wrap around (may cause duplicates)
{
emsg(_("W14: Warning: List of file names overflow"));
! if (emsg_silent == 0)
{
out_flush();
ui_delay(3001L, TRUE); // make sure it is noticed
--- 2154,2160 ----
if (top_file_num < 0) // wrap around (may cause duplicates)
{
emsg(_("W14: Warning: List of file names overflow"));
! if (emsg_silent == 0 && !in_assert_fails)
{
out_flush();
ui_delay(3001L, TRUE); // make sure it is noticed
*** ../vim-8.2.1918/src/change.c 2020-10-24 20:49:37.490683063 +0200
--- src/change.c 2020-10-28 18:24:05.711660331 +0100
***************
*** 115,121 ****
// Wait two seconds, to make sure the user reads this unexpected
// message. Since we could be anywhere, call wait_return() now,
// and don't let the emsg() set msg_scroll.
! if (need_wait_return && emsg_silent == 0)
{
out_flush();
ui_delay(2002L, TRUE);
--- 115,121 ----
// Wait two seconds, to make sure the user reads this unexpected
// message. Since we could be anywhere, call wait_return() now,
// and don't let the emsg() set msg_scroll.
! if (need_wait_return && emsg_silent == 0 && !in_assert_fails)
{
out_flush();
ui_delay(2002L, TRUE);
*** ../vim-8.2.1918/src/fileio.c 2020-10-24 20:49:37.494683051 +0200
--- src/fileio.c 2020-10-28 18:39:47.548977379 +0100
***************
*** 4208,4214 ****
msg_puts_attr(mesg2, HL_ATTR(HLF_W) + MSG_HIST);
msg_clr_eos();
(void)msg_end();
! if (emsg_silent == 0)
{
out_flush();
#ifdef FEAT_GUI
--- 4208,4214 ----
msg_puts_attr(mesg2, HL_ATTR(HLF_W) + MSG_HIST);
msg_clr_eos();
(void)msg_end();
! if (emsg_silent == 0 && !in_assert_fails)
{
out_flush();
#ifdef FEAT_GUI
*** ../vim-8.2.1918/src/insexpand.c 2020-10-27 09:12:41.136329137 +0100
--- src/insexpand.c 2020-10-28 18:39:04.945097435 +0100
***************
*** 298,304 ****
msg_attr(dict_opt ? _("'dictionary' option is empty")
: _("'thesaurus' option is empty"),
HL_ATTR(HLF_E));
! if (emsg_silent == 0)
{
vim_beep(BO_COMPL);
setcursor();
--- 298,304 ----
msg_attr(dict_opt ? _("'dictionary' option is empty")
: _("'thesaurus' option is empty"),
HL_ATTR(HLF_E));
! if (emsg_silent == 0 && !in_assert_fails)
{
vim_beep(BO_COMPL);
setcursor();
*** ../vim-8.2.1918/src/message.c 2020-10-24 20:49:37.498683038 +0200
--- src/message.c 2020-10-28 19:05:39.800654160 +0100
***************
*** 659,665 ****
return TRUE;
}
! if (emsg_assert_fails_used && emsg_assert_fails_msg == NULL)
{
emsg_assert_fails_msg = vim_strsave(s);
emsg_assert_fails_lnum = SOURCING_LNUM;
--- 659,665 ----
return TRUE;
}
! if (in_assert_fails && emsg_assert_fails_msg == NULL)
{
emsg_assert_fails_msg = vim_strsave(s);
emsg_assert_fails_lnum = SOURCING_LNUM;
*** ../vim-8.2.1918/src/misc1.c 2020-10-22 21:22:54.744905305 +0200
--- src/misc1.c 2020-10-28 18:37:53.317300552 +0100
***************
*** 1063,1069 ****
called_vim_beep = TRUE;
#endif
! if (emsg_silent == 0)
{
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
{
--- 1063,1069 ----
called_vim_beep = TRUE;
#endif
! if (emsg_silent == 0 && !in_assert_fails)
{
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
{
***************
*** 2568,2573 ****
--- 2568,2574 ----
* But don't allow a space in the path, so that this works:
* "/usr/bin/csh --rcfile ~/.cshrc"
* But don't do that for Windows, it's common to have a space in the path.
+ * Returns NULL when out of memory.
*/
char_u *
get_isolated_shell_name(void)
*** ../vim-8.2.1918/src/normal.c 2020-09-08 22:45:31.113504961 +0200
--- src/normal.c 2020-10-28 18:37:09.513425655 +0100
***************
*** 1154,1159 ****
--- 1154,1160 ----
&& stuff_empty()
&& typebuf_typed()
&& emsg_silent == 0
+ && !in_assert_fails
&& !did_wait_return
&& oap->op_type == OP_NOP)
{
*** ../vim-8.2.1918/src/screen.c 2020-10-26 21:05:23.905469139 +0100
--- src/screen.c 2020-10-28 18:35:52.889646302 +0100
***************
*** 2490,2496 ****
{
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
&& !did_wait_return
! && emsg_silent == 0)
{
out_flush();
ui_delay(1006L, TRUE);
--- 2490,2497 ----
{
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
&& !did_wait_return
! && emsg_silent == 0
! && !in_assert_fails)
{
out_flush();
ui_delay(1006L, TRUE);
*** ../vim-8.2.1918/src/term.c 2020-10-07 16:12:33.905930345 +0200
--- src/term.c 2020-10-28 18:35:28.833716091 +0100
***************
*** 1800,1806 ****
mch_errmsg(_("defaulting to '"));
mch_errmsg((char *)term);
mch_errmsg("'\r\n");
! if (emsg_silent == 0)
{
screen_start(); // don't know where cursor is now
out_flush();
--- 1800,1806 ----
mch_errmsg(_("defaulting to '"));
mch_errmsg((char *)term);
mch_errmsg("'\r\n");
! if (emsg_silent == 0 && !in_assert_fails)
{
screen_start(); // don't know where cursor is now
out_flush();
*** ../vim-8.2.1918/src/vim9execute.c 2020-10-28 16:54:43.689269256 +0100
--- src/vim9execute.c 2020-10-28 18:50:42.019177934 +0100
***************
*** 582,588 ****
funcexe_T funcexe;
int error;
int idx;
! int called_emsg_before = called_emsg;
if (ufunc->uf_def_status == UF_TO_BE_COMPILED
&& compile_def_function(ufunc, FALSE, NULL) == FAIL)
--- 582,588 ----
funcexe_T funcexe;
int error;
int idx;
! int did_emsg_before = did_emsg;
if (ufunc->uf_def_status == UF_TO_BE_COMPILED
&& compile_def_function(ufunc, FALSE, NULL) == FAIL)
***************
*** 620,626 ****
user_func_error(error, ufunc->uf_name);
return FAIL;
}
! if (called_emsg > called_emsg_before)
// Error other than from calling the function itself.
return FAIL;
return OK;
--- 620,626 ----
user_func_error(error, ufunc->uf_name);
return FAIL;
}
! if (did_emsg > did_emsg_before)
// Error other than from calling the function itself.
return FAIL;
return OK;
*** ../vim-8.2.1918/src/testdir/test_vim9_func.vim 2020-10-28 16:54:43.689269256 +0100
--- src/testdir/test_vim9_func.vim 2020-10-28 18:49:04.199443271 +0100
***************
*** 1467,1480 ****
g:did_it = 'yes'
enddef
! "func UserError()
! " silent! invalid
! "endfunc
! "
! "def SilentlyUserError()
! " UserError()
! " g:did_it = 'yes'
! "enddef
" This can't be a :def function, because the assert would not be reached.
" And this must not be inside a try/endtry.
--- 1467,1480 ----
g:did_it = 'yes'
enddef
! func UserError()
! silent! invalid
! endfunc
!
! def SilentlyUserError()
! UserError()
! g:did_it = 'yes'
! enddef
" This can't be a :def function, because the assert would not be reached.
" And this must not be inside a try/endtry.
***************
*** 1483,1492 ****
call SilentlyError()
call assert_equal('yes', g:did_it)
! " this doesn't work yet
! " let g:did_it = 'no'
! " call SilentlyUserError()
! " call assert_equal('yes', g:did_it)
unlet g:did_it
endfunc
--- 1483,1491 ----
call SilentlyError()
call assert_equal('yes', g:did_it)
! let g:did_it = 'no'
! call SilentlyUserError()
! call assert_equal('yes', g:did_it)
unlet g:did_it
endfunc
*** ../vim-8.2.1918/src/testdir/gen_opt_test.vim 2020-09-23 22:38:01.503927513 +0200
--- src/testdir/gen_opt_test.vim 2020-10-28 19:29:47.944424952 +0100
***************
*** 200,207 ****
" setting an option can only fail when it's implemented.
call add(script, "if exists('+" . name . "')")
for val in a[1]
! call add(script, "call assert_fails('set " . name . "=" . val . "')")
! call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
endfor
call add(script, "endif")
endif
--- 200,207 ----
" setting an option can only fail when it's implemented.
call add(script, "if exists('+" . name . "')")
for val in a[1]
! call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
! call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
endfor
call add(script, "endif")
endif
*** ../vim-8.2.1918/src/testdir/test_autocmd.vim 2020-10-11 20:08:39.448720572 +0200
--- src/testdir/test_autocmd.vim 2020-10-28 19:44:31.837950650 +0100
***************
*** 194,200 ****
exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
augroup END
! call assert_fails('edit bb.txt', ['E937:', 'E517:'])
autocmd! test_autocmd_bufunload
augroup! test_autocmd_bufunload
--- 194,200 ----
exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
augroup END
! call assert_fails('edit bb.txt', 'E937:')
autocmd! test_autocmd_bufunload
augroup! test_autocmd_bufunload
***************
*** 1768,1774 ****
func Test_nocatch_wipe_all_buffers()
" Real nasty autocommand: wipe all buffers on any event.
au * * bwipe *
! call assert_fails('next x', ['E94:', 'E517:'])
bwipe
au!
endfunc
--- 1768,1774 ----
func Test_nocatch_wipe_all_buffers()
" Real nasty autocommand: wipe all buffers on any event.
au * * bwipe *
! call assert_fails('next x', ['E94:', 'E937:'])
bwipe
au!
endfunc
*** ../vim-8.2.1918/src/testdir/test_mapping.vim 2020-08-12 18:50:31.879655802 +0200
--- src/testdir/test_mapping.vim 2020-10-28 20:00:51.015226812 +0100
***************
*** 681,687 ****
" invalid <expr> abbreviation
abbr <expr> hte GetAbbr()
call assert_fails('normal ihte ', 'E117:')
! call assert_equal(' ', getline(1))
unabbr <expr> hte
close!
--- 681,687 ----
" invalid <expr> abbreviation
abbr <expr> hte GetAbbr()
call assert_fails('normal ihte ', 'E117:')
! call assert_equal('', getline(1))
unabbr <expr> hte
close!
*** ../vim-8.2.1918/src/testdir/test_popup.vim 2020-07-11 22:14:54.314422214 +0200
--- src/testdir/test_popup.vim 2020-10-28 20:11:06.477523070 +0100
***************
*** 344,350 ****
/^one
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E578:')
call assert_equal(winid, win_getid())
! call assert_equal('oneDEF', getline(1))
q!
endfunc
--- 344,350 ----
/^one
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E578:')
call assert_equal(winid, win_getid())
! call assert_equal('onedef', getline(1))
q!
endfunc
*** ../vim-8.2.1918/src/testdir/test_terminal.vim 2020-09-29 21:23:17.881461813 +0200
--- src/testdir/test_terminal.vim 2020-10-28 20:13:27.241133610 +0100
***************
*** 65,71 ****
setlocal modifiable
exe "normal Axxx\<Esc>"
! call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
undo
exe buf . 'bwipe'
--- 65,71 ----
setlocal modifiable
exe "normal Axxx\<Esc>"
! call assert_fails(buf . 'bwipe', 'E89:')
undo
exe buf . 'bwipe'
***************
*** 89,95 ****
func Test_terminal_wipe_buffer()
let buf = Run_shell_in_terminal({})
! call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
exe buf . 'bwipe!'
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
call assert_equal("", bufname(buf))
--- 89,95 ----
func Test_terminal_wipe_buffer()
let buf = Run_shell_in_terminal({})
! call assert_fails(buf . 'bwipe', 'E89:')
exe buf . 'bwipe!'
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
call assert_equal("", bufname(buf))
***************
*** 648,654 ****
func Test_terminal_list_args()
let buf = term_start([&shell, &shellcmdflag, 'echo "123"'])
! call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
exe buf . 'bwipe!'
call assert_equal("", bufname(buf))
endfunction
--- 648,654 ----
func Test_terminal_list_args()
let buf = term_start([&shell, &shellcmdflag, 'echo "123"'])
! call assert_fails(buf . 'bwipe', 'E89:')
exe buf . 'bwipe!'
call assert_equal("", bufname(buf))
endfunction
*** ../vim-8.2.1918/src/version.c 2020-10-28 17:55:26.440231132 +0100
--- src/version.c 2020-10-28 19:30:36.524289731 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1919,
/**/
--
hundred-and-one symptoms of being an internet addict:
146. You experience ACTUAL physical withdrawal symptoms when away
from your 'puter and the net.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///