diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 6bf5bf2..ca4808b 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -205,11 +205,11 @@ class DebugSession( object ): def _Reset( self ): if self._uiTab: + vim.current.tabpage = self._uiTab self._stackTraceView.Reset() self._variablesView.Reset() self._outputView.Reset() self._codeView.Reset() - vim.current.tabpage = self._uiTab vim.command( 'tabclose!' ) self._uiTab = None diff --git a/run_test_vim b/run_test_vim deleted file mode 100755 index 6d79b4b..0000000 --- a/run_test_vim +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -RUN_VIM="vim --noplugin --clean --not-a-term -Nu vimrc" -RUN_TEST="${RUN_VIM} -S run_test.vim" - -pushd tests > /dev/null - -exec $RUN_VIM "$@" diff --git a/run_tests b/run_tests index d79de1a..fd83465 100755 --- a/run_tests +++ b/run_tests @@ -1,8 +1,21 @@ #!/usr/bin/env bash -RUN_VIM="vim --noplugin --clean --not-a-term" +RUN_VIM="vim --clean --not-a-term" RUN_TEST="${RUN_VIM} -S run_test.vim" +if [ -z "$VIMSPECTOR_MIMODE" ]; then + if which -s lldb; then + export VIMSPECTOR_MIMODE=lldb + elif which -s gdb; then + export VIMSPECTOR_MIMODE=gdb + else + echo "Couldn't guess VIMSPECTOR_MIMODE. Need lldb or gdb in path" + exit 1 + fi +fi + +echo "Testing with VIMSPECTOR_MIMODE=$VIMSPECTOR_MIMODE" + echo "%SETUP - Building test programs..." set -e pushd tests/testdata/cpp/simple @@ -17,12 +30,21 @@ echo "Running Vimspector Vim tests" RESULT=0 -for t in *.test.vim; do +TESTS="$@" + +if [ -z "$TESTS" ]; then + TESTS=*.test.vim +fi + +for t in ${TESTS}; do echo "" echo "%RUN: $t" rm -f messages debuglog - if ${RUN_TEST} $t --cmd 'au SwapExists * let v:swapchoice = "e"'; then + # split on : into fileName and testName + IFS=: read -s t T <<< "$t" + + if ${RUN_TEST} --cmd 'au SwapExists * let v:swapchoice = "e"' $t $T; then echo "%PASS: $t PASSED" else cat messages diff --git a/support/test/run_test_vim b/support/test/run_test_vim new file mode 100755 index 0000000..beb27b2 --- /dev/null +++ b/support/test/run_test_vim @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +exec vim \ + --clean \ + --not-a-term \ + --cmd "let g:vimspector_enable_mappings='HUMAN'" \ + -Nu $(dirname $0)/../../tests/vimrc \ + "$@" diff --git a/tests/breakpoints.test.vim b/tests/breakpoints.test.vim index d0ed81e..a9043a6 100644 --- a/tests/breakpoints.test.vim +++ b/tests/breakpoints.test.vim @@ -54,14 +54,14 @@ endfunction function! Test_Signs_Placed_Using_API_Are_Shown() " We need a real file edit testdata/cpp/simple/simple.cpp - call feedkeys( "/printf\", 'x' ) + call feedkeys( "/printf\", 'xt' ) " Set breakpoint call vimspector#ToggleBreakpoint() call assert_true( exists( '*vimspector#ToggleBreakpoint' ) ) - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -73,7 +73,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown() " Disable breakpoint call vimspector#ToggleBreakpoint() - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -85,7 +85,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown() " Remove breakpoint call vimspector#ToggleBreakpoint() - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -94,7 +94,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown() call assert_equal( 0, len( signs[ 0 ].signs ) ) call vimspector#ClearBreakpoints() - bwipeout! + %bwipeout! endfunction function! SetUp_Test_Use_Mappings_HUMAN() @@ -109,9 +109,9 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 15, line( '.' ) ) " Add the breakpoing - call feedkeys( "\", 'x' ) + call feedkeys( "\", 'xt' ) - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -121,9 +121,9 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name ) " Disable the breakpoint - call feedkeys( "\", 'x' ) + call feedkeys( "\", 'xt' ) - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -132,9 +132,9 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 'vimspectorBPDisabled', signs[ 0 ].signs[ 0 ].name ) " Delete the breakpoint - call feedkeys( "\", 'x' ) + call feedkeys( "\", 'xt' ) - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -142,9 +142,9 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 0, len( signs[ 0 ].signs ) ) " Add it again - call feedkeys( "\", 'x' ) + call feedkeys( "\", 'xt' ) - let signs = sign_getplaced( '.', { + let signs = sign_getplaced( '%', { \ 'group': 'VimspectorBP', \ 'line': line( '.' ) \ } ) @@ -154,12 +154,22 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name ) " Here we go. Start Debugging - call feedkeys( "\", 'x' ) + call feedkeys( "\", 'xt' ) + + call assert_equal( 2, len( gettabinfo() ) ) + let cur_tabnr = tabpagenr() + call assert_equal( 5, len( gettabinfo( cur_tabnr )[ 0 ].windows ) ) call vimspector#Reset() call vimspector#ClearBreakpoints() + let signs = sign_getplaced( '%', { + \ 'group': 'VimspectorBP' + \ } ) + call assert_equal( 1, len( signs ), 1 ) + call assert_equal( 0, len( signs[ 0 ].signs ) ) + lcd - - bwipeout! + %bwipeout! endfunction diff --git a/tests/run_test.vim b/tests/run_test.vim index de454cb..a5c0e80 100644 --- a/tests/run_test.vim +++ b/tests/run_test.vim @@ -83,6 +83,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -97,6 +99,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -111,6 +115,7 @@ func RunTheTest(test) else try let s:test = a:test + let s:testid = g:testpath . ':' . a:test au VimLeavePre * call EarlyExit(s:test) exe 'call ' . a:test au! VimLeavePre @@ -126,6 +131,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -143,6 +150,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -156,6 +165,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -187,7 +198,7 @@ endfunc func AfterTheTest() if len(v:errors) > 0 let s:fail += 1 - call add(s:errors, 'Found errors in ' . s:test . ':') + call add(s:errors, 'Found errors in ' . s:testid . ':') call extend(s:errors, v:errors) let v:errors = [] endif @@ -219,7 +230,7 @@ func FinishTesting() " Append errors to test.log split test.log call append(line('$'), '') - call append(line('$'), 'From ' . g:testname . ':') + call append(line('$'), 'From ' . g:testpath . ':') call append(line('$'), s:errors) write endif @@ -244,7 +255,7 @@ func FinishTesting() " Append messages to the file "messages" split messages call append(line('$'), '') - call append(line('$'), 'From ' . g:testname . ':') + call append(line('$'), 'From ' . g:testpath . ':') call append(line('$'), s:messages) write @@ -258,6 +269,7 @@ endfunc " Source the test script. First grab the file name, in case the script " navigates away. g:testname can be used by the tests. let g:testname = expand('%') +let g:testpath = expand('%:p') let s:done = 0 let s:fail = 0 let s:errors = [] @@ -307,7 +319,7 @@ for s:test in sort(s:tests) \ && (index(s:flaky_tests, s:test) >= 0 \ || v:errors[0] =~ s:flaky_errors_re) while 1 - call add(s:messages, 'Found errors in ' . s:test . ':') + call add(s:messages, 'Found errors in ' . s:testid . ':') call extend(s:messages, v:errors) call add(total_errors, 'Run ' . run_nr . ':') diff --git a/tests/vimrc b/tests/vimrc index 9901c3a..e845f78 100644 --- a/tests/vimrc +++ b/tests/vimrc @@ -1,4 +1,5 @@ -let g:vimspector_test_plugin_path = expand( ':h:h' ) +let g:vimspector_test_plugin_path = expand( ':p:h:h' ) +set mouse=a let &rtp = &rtp . ',' . g:vimspector_test_plugin_path