Skip to content

Commit 8903676

Browse files
committed
patch 8.1.0044: if a test function exists Vim this may go unnoticed
Problem: If a test function exists Vim this may go unnoticed. Solution: Check for a test funtion quitting Vim. Fix tests that did exit Vim.
1 parent 7580849 commit 8903676

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/testdir/runtest.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ func RunTheTest(test)
124124
exe 'call ' . a:test
125125
else
126126
try
127+
let s:test = a:test
128+
au VimLeavePre * call EarlyExit(s:test)
127129
exe 'call ' . a:test
130+
au! VimLeavePre
128131
catch /^\cskipped/
129132
call add(s:messages, ' Skipped')
130133
call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', ''))
@@ -174,6 +177,15 @@ func AfterTheTest()
174177
endif
175178
endfunc
176179

180+
func EarlyExit(test)
181+
" It's OK for the test we use to test the quit detection.
182+
if a:test != 'Test_zz_quit_detected()'
183+
call add(v:errors, 'Test caused Vim to exit: ' . a:test)
184+
endif
185+
186+
call FinishTesting()
187+
endfunc
188+
177189
" This function can be called by a test if it wants to abort testing.
178190
func FinishTesting()
179191
call AfterTheTest()

src/testdir/test_assert.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,9 @@ func Test_user_is_happy()
198198
smile
199199
sleep 300m
200200
endfunc
201+
202+
" Must be last.
203+
func Test_zz_quit_detected()
204+
" Verify that if a test function ends Vim the test script detects this.
205+
quit
206+
endfunc

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
44,
764766
/**/
765767
43,
766768
/**/

0 commit comments

Comments
 (0)