Skip to content

Commit f220643

Browse files
committed
patch 9.0.0846: using assert_fails() may cause hit-enter prompt
Problem: Using assert_fails() may cause hit-enter prompt. Solution: Set no_wait_return. (closes #11522)
1 parent 4e7590e commit f220643

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/testdir/test_assert.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ func Test_assert_fails_in_try_block()
338338
endtry
339339
endfunc
340340

341+
func Test_assert_fails_in_timer()
342+
" should not cause a hit-enter prompt, which isn't actually checked here
343+
call timer_start(0, {-> assert_fails('call', 'E471:')})
344+
sleep 10m
345+
endfunc
346+
341347
func Test_assert_beeps()
342348
new
343349
call assert_equal(0, assert_beeps('normal h'))

src/testing.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ f_assert_exception(typval_T *argvars, typval_T *rettv)
592592
void
593593
f_assert_fails(typval_T *argvars, typval_T *rettv)
594594
{
595-
char_u *cmd;
596595
garray_T ga;
597596
int save_trylevel = trylevel;
598597
int called_emsg_before = called_emsg;
@@ -608,13 +607,13 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
608607
&& check_for_opt_string_arg(argvars, 4) == FAIL)))))
609608
return;
610609

611-
cmd = tv_get_string_chk(&argvars[0]);
612-
613610
// trylevel must be zero for a ":throw" command to be considered failed
614611
trylevel = 0;
615612
suppress_errthrow = TRUE;
616613
in_assert_fails = TRUE;
614+
++no_wait_return;
617615

616+
char_u *cmd = tv_get_string_chk(&argvars[0]);
618617
do_cmdline_cmd(cmd);
619618

620619
// reset here for any errors reported below
@@ -758,6 +757,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
758757
did_emsg = FALSE;
759758
got_int = FALSE;
760759
msg_col = 0;
760+
--no_wait_return;
761761
need_wait_return = FALSE;
762762
emsg_on_display = FALSE;
763763
msg_scrolled = 0;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
846,
698700
/**/
699701
845,
700702
/**/

0 commit comments

Comments
 (0)