From 34df47fe35f83c088a40ce81065da15f2761bcbe Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 21 Jul 2019 17:18:13 +0100 Subject: [PATCH] Make reset reliable by waiting for it to finish --- tests/breakpoints.test.vim | 17 ++++++----------- tests/lib/autoload/vimspector/test/setup.vim | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/breakpoints.test.vim b/tests/breakpoints.test.vim index 6aac934..7e12308 100644 --- a/tests/breakpoints.test.vim +++ b/tests/breakpoints.test.vim @@ -154,7 +154,10 @@ function! Test_Use_Mappings_HUMAN() normal 0 call AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) - " Add the breakpoing + call AssertSignGroupEmptyAtLine( 'VimspectorBP', + \ 15 ) + + " Add the breakpoint call feedkeys( "\", 'xt' ) call AssertSignGroupSingletonAtLine( 'VimspectorBP', \ 15, @@ -191,11 +194,7 @@ function! Test_Use_Mappings_HUMAN() call AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 ) call AssertPCIsAtLineInBuffer( '%', 16 ) - call vimspector#Reset() - call AssertSignGroupEmpty( 'VimspectorCode' ) - - call vimspector#ClearBreakpoints() - call AssertSignGroupEmpty( 'VimspectorBP' ) + call vimspector#test#setup#Reset() lcd - %bwipeout! @@ -215,11 +214,7 @@ function Test_StopAtEntry() call AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) call AssertPCIsAtLineInBuffer( 'simple.cpp', 15 ) - call vimspector#Reset() - call AssertSignGroupEmpty( 'VimspectorCode' ) - - call vimspector#ClearBreakpoints() - call AssertSignGroupEmpty( 'VimspectorBP' ) + call vimspector#test#setup#Reset() lcd - %bwipeout! diff --git a/tests/lib/autoload/vimspector/test/setup.vim b/tests/lib/autoload/vimspector/test/setup.vim index dfd193a..39866ad 100644 --- a/tests/lib/autoload/vimspector/test/setup.vim +++ b/tests/lib/autoload/vimspector/test/setup.vim @@ -1,4 +1,4 @@ -function! vimspector#test#setup#SetUpWithMappings( mappings ) +function! vimspector#test#setup#SetUpWithMappings( mappings ) abort if exists ( 'g:loaded_vimpector' ) unlet g:loaded_vimpector endif @@ -13,8 +13,21 @@ function! vimspector#test#setup#SetUpWithMappings( mappings ) runtime! plugin/**/*.vim endfunction -function! vimspector#test#setup#ClearDown() +function! vimspector#test#setup#ClearDown() abort if exists( '*vimspector#internal#state#Reset' ) call vimspector#internal#state#Reset() endif endfunction + +function! vimspector#test#setup#Reset() abort + call vimspector#Reset() + call AssertSignGroupEmpty( 'VimspectorCode' ) + + call vimspector#ClearBreakpoints() + call AssertSignGroupEmpty( 'VimspectorBP' ) + + call WaitForAssert( {-> + \ assert_true( pyxeval( '_vimspector_session._connection is None' ) ) + \ } ) +endfunction +