Skip to content

Commit dae453f

Browse files
committed
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Problem: Vim9: check for DO_NOT_FREE_CNT is very slow. Solution: Move to a separate function so it can be skipped by setting $TEST_SKIP_PAT.
1 parent 4270d8b commit dae453f

3 files changed

Lines changed: 51 additions & 3 deletions

File tree

src/testdir/runtest.vim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
" For csh:
1414
" setenv TEST_FILTER Test_channel
1515
"
16+
" If the environment variable $TEST_SKIP_PAT is set then test functions
17+
" matching this pattern will be skipped. It's the opposite of $TEST_FILTER.
18+
"
1619
" While working on a test you can make $TEST_NO_RETRY non-empty to not retry:
1720
" export TEST_NO_RETRY=yes
1821
"
@@ -329,13 +332,17 @@ func FinishTesting()
329332

330333
if s:done == 0
331334
if s:filtered > 0
332-
let message = "NO tests match $TEST_FILTER: '" .. $TEST_FILTER .. "'"
335+
if $TEST_FILTER != ''
336+
let message = "NO tests match $TEST_FILTER: '" .. $TEST_FILTER .. "'"
337+
else
338+
let message = "ALL tests match $TEST_SKIP_PAT: '" .. $TEST_SKIP_PAT .. "'"
339+
endif
333340
else
334341
let message = 'NO tests executed'
335342
endif
336343
else
337344
if s:filtered > 0
338-
call add(s:messages, "Filtered " .. s:filtered .. " tests with $TEST_FILTER")
345+
call add(s:messages, "Filtered " .. s:filtered .. " tests with $TEST_FILTER and $TEST_SKIP_PAT")
339346
endif
340347
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
341348
endif
@@ -461,6 +468,12 @@ endif
461468

462469
" Execute the tests in alphabetical order.
463470
for g:testfunc in sort(s:tests)
471+
if $TEST_SKIP_PAT != '' && g:testfunc =~ $TEST_SKIP_PAT
472+
call add(s:messages, g:testfunc .. ' matches $TEST_SKIP_PAT')
473+
let s:filtered += 1
474+
continue
475+
endif
476+
464477
" Silence, please!
465478
set belloff=all
466479
let prev_error = ''

src/testdir/test_vim9_expr.vim

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,14 +2832,47 @@ def Test_expr7_namespace()
28322832
assert_equal('some', get(t:, 'some_var', 'xxx'))
28332833
assert_equal('xxx', get(t:, 'no_var', 'xxx'))
28342834
unlet t:some_var
2835+
END
2836+
CheckDefAndScriptSuccess(lines)
2837+
enddef
28352838

2839+
def Test_expr7_namespace_loop_def()
2840+
var lines =<< trim END
28362841
# check using g: in a for loop more than DO_NOT_FREE_CNT times
2842+
var exists = 0
2843+
var exists_not = 0
28372844
for i in range(100000)
28382845
if has_key(g:, 'does-not-exist')
2846+
exists += 1
2847+
else
2848+
exists_not += 1
28392849
endif
28402850
endfor
2851+
assert_equal(0, exists)
2852+
assert_equal(100000, exists_not)
28412853
END
2842-
CheckDefAndScriptSuccess(lines)
2854+
CheckDefSuccess(lines)
2855+
enddef
2856+
2857+
" NOTE: this is known to be slow. To skip use:
2858+
" :let $TEST_SKIP_PAT = 'Test_expr7_namespace_loop_script'
2859+
def Test_expr7_namespace_loop_script()
2860+
var lines =<< trim END
2861+
vim9script
2862+
# check using g: in a for loop more than DO_NOT_FREE_CNT times
2863+
var exists = 0
2864+
var exists_not = 0
2865+
for i in range(100000)
2866+
if has_key(g:, 'does-not-exist')
2867+
exists += 1
2868+
else
2869+
exists_not += 1
2870+
endif
2871+
endfor
2872+
assert_equal(0, exists)
2873+
assert_equal(100000, exists_not)
2874+
END
2875+
CheckScriptSuccess(lines)
28432876
enddef
28442877

28452878
def Test_expr7_parens()

src/version.c

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

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3311,
758760
/**/
759761
3310,
760762
/**/

0 commit comments

Comments
 (0)