From 8bea171f154845046239c61bdef50a8e0f12f643 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 15 Jun 2022 20:49:35 +0100 Subject: patch 8.2.5102: interrupt not caught in test Problem: Interrupt not caught in test. Solution: Consider an exception thrown in the current try/catch when got_int is set. Also catch early exit when not using try/catch. --- src/testdir/runtest.vim | 4 ++-- src/testdir/test_retab.vim | 30 ++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'src/testdir') diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index db6797d1b0..c7d5704e9a 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -201,6 +201,7 @@ func RunTheTest(test) endtry endif + au VimLeavePre * call EarlyExit(g:testfunc) if a:test =~ 'Test_nocatch_' " Function handles errors itself. This avoids skipping commands after the " error. @@ -212,9 +213,7 @@ func RunTheTest(test) endif else try - au VimLeavePre * call EarlyExit(g:testfunc) exe 'call ' . a:test - au! VimLeavePre catch /^\cskipped/ call add(s:messages, ' Skipped') call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) @@ -222,6 +221,7 @@ func RunTheTest(test) call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) endtry endif + au! VimLeavePre " In case 'insertmode' was set and something went wrong, make sure it is " reset to avoid trouble with anything else. diff --git a/src/testdir/test_retab.vim b/src/testdir/test_retab.vim index 34ab7e1f99..2d96042dc1 100644 --- a/src/testdir/test_retab.vim +++ b/src/testdir/test_retab.vim @@ -82,20 +82,34 @@ func Test_retab_error() call assert_fails('ret 80000000000000000000', 'E475:') endfunc -" FIXME: the try/catch does not catch the interrupt -func FIXME_Test_retab_endless() +func RetabLoop() + while 1 + set ts=4000 + retab 4 + endwhile +endfunc + +func Test_retab_endless() + " inside try/catch we catch the error message new call setline(1, "\t0\t") let caught = 'no' try - while 1 - set ts=4000 - retab 4 - endwhile - catch + call RetabLoop() + catch /E1240:/ let caught = v:exception endtry - call assert_notequal('no', caught) + call assert_match('E1240:', caught) + bwipe! + set tabstop& +endfunc + +func Test_nocatch_retab_endless() + " not inside try/catch an interrupt is generated to get out of loops + new + call setline(1, "\t0\t") + call assert_fails('call RetabLoop()', ['E1240:', 'Interrupted']) + bwipe! set tabstop& endfunc -- cgit v1.2.3