Skip to content

Commit

Permalink
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Browse files Browse the repository at this point in the history
Problem:    test_garbagecollect_now() does not check v:testing as documented.
Solution:   Give an error if v:testing is not set.
  • Loading branch information
brammool committed Jan 27, 2022
1 parent a4bc2dd commit b3d8398
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,8 @@ EXTERN char e_for_argument_must_be_sequence_of_lists[]
INIT(= N_("E1140: :for argument must be a sequence of lists"));
EXTERN char e_indexable_type_required[]
INIT(= N_("E1141: Indexable type required"));
// E1142 unused
EXTERN char e_calling_test_garbagecollect_now_while_v_testing_is_not_set[]
INIT(= N_("E1142: Calling test_garbagecollect_now() while v:testing is not set"));
EXTERN char e_empty_expression_str[]
INIT(= N_("E1143: Empty expression: \"%s\""));
EXTERN char e_command_str_not_followed_by_white_space_str[]
Expand Down
6 changes: 6 additions & 0 deletions src/testdir/test_functions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,12 @@ func Test_range()
call assert_fails('let x=range(1, 4, [])', 'E745:')
endfunc

func Test_garbagecollect_now_fails()
let v:testing = 0
call assert_fails('call test_garbagecollect_now()', 'E1142:')
let v:testing = 1
endfunc

func Test_echoraw()
CheckScreendump

Expand Down
5 changes: 4 additions & 1 deletion src/testing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,10 @@ f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
// This is dangerous, any Lists and Dicts used internally may be freed
// while still in use.
garbage_collect(TRUE);
if (!get_vim_var_nr(VV_TESTING))
emsg(_(e_calling_test_garbagecollect_now_while_v_testing_is_not_set));
else
garbage_collect(TRUE);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4234,
/**/
4233,
/**/
Expand Down

0 comments on commit b3d8398

Please sign in to comment.