diff options
-rw-r--r-- | src/nvim/testdir/runtest.vim | 12 | ||||
-rw-r--r-- | src/nvim/testdir/test_assert.vim | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index e0d73c5a1e..6f039509f3 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -124,7 +124,10 @@ func RunTheTest(test) exe 'call ' . a:test else try + let s:test = a:test + au VimLeavePre * call EarlyExit(s:test) 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\+', '', '')) @@ -178,6 +181,15 @@ func AfterTheTest() endif endfunc +func EarlyExit(test) + " It's OK for the test we use to test the quit detection. + if a:test != 'Test_zz_quit_detected()' + call add(v:errors, 'Test caused Vim to exit: ' . a:test) + endif + + call FinishTesting() +endfunc + " This function can be called by a test if it wants to abort testing. func FinishTesting() call AfterTheTest() diff --git a/src/nvim/testdir/test_assert.vim b/src/nvim/testdir/test_assert.vim new file mode 100644 index 0000000000..fe87bd6ef5 --- /dev/null +++ b/src/nvim/testdir/test_assert.vim @@ -0,0 +1,7 @@ +" Test that the methods used for testing work. + +" Must be last. +func Test_zz_quit_detected() + " Verify that if a test function ends Vim the test script detects this. + quit +endfunc |