From 652fc4d280dfecbd918dabad09a5c5a63af06ace Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 28 Apr 2019 14:30:42 +0100 Subject: [PATCH 1/5] Default VIMSPECTOR_MIMODE --- run_tests | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/run_tests b/run_tests index d79de1a..709b2f2 100755 --- a/run_tests +++ b/run_tests @@ -3,6 +3,19 @@ RUN_VIM="vim --noplugin --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 From a2fac43d297b7668d2aa949739518d6f80446d73 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 28 Apr 2019 14:31:25 +0100 Subject: [PATCH 2/5] Move rarely useful script out of the way --- run_test_vim => support/test/run_test_vim | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename run_test_vim => support/test/run_test_vim (100%) diff --git a/run_test_vim b/support/test/run_test_vim similarity index 100% rename from run_test_vim rename to support/test/run_test_vim From f6e4b6cc5d389f61d75a4416b89f83b3a661cef1 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 4 May 2019 16:56:41 +0100 Subject: [PATCH 3/5] Read tests from command line and print test file name on failure --- run_tests | 13 +++++++++++-- tests/breakpoints.test.vim | 7 +++++++ tests/run_test.vim | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/run_tests b/run_tests index 709b2f2..04e4c40 100755 --- a/run_tests +++ b/run_tests @@ -30,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/tests/breakpoints.test.vim b/tests/breakpoints.test.vim index d0ed81e..fdf6933 100644 --- a/tests/breakpoints.test.vim +++ b/tests/breakpoints.test.vim @@ -160,6 +160,13 @@ function! Test_Use_Mappings_HUMAN() 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! endfunction diff --git a/tests/run_test.vim b/tests/run_test.vim index de454cb..3cfae67 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 @@ -126,6 +130,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -143,6 +149,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -156,6 +164,8 @@ func RunTheTest(test) \ . ': ' \ . v:exception \ . ' @ ' + \ . g:testpath + \ . ':' \ . v:throwpoint) endtry endif @@ -219,7 +229,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 +254,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 +268,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 = [] From 13f92e7d9bf76b987206619671f029797066f02a Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 5 May 2019 15:36:33 +0100 Subject: [PATCH 4/5] Update tests so they actually test and pass --- tests/breakpoints.test.vim | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/breakpoints.test.vim b/tests/breakpoints.test.vim index fdf6933..c3f5978 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,19 +154,19 @@ 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 vimspector#Reset() call vimspector#ClearBreakpoints() - let signs = sign_getplaced( '.', { - \ 'group': 'VimspectorBP', + 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 From 132b284dcd8561fd15d13d517aadb90c6c98008b Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Wed, 8 May 2019 23:24:06 +0100 Subject: [PATCH 5/5] Improve tests --- python3/vimspector/debug_session.py | 2 +- run_tests | 2 +- support/test/run_test_vim | 12 ++++++------ tests/breakpoints.test.vim | 5 ++++- tests/run_test.vim | 5 +++-- tests/vimrc | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) 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_tests b/run_tests index 04e4c40..fd83465 100755 --- a/run_tests +++ b/run_tests @@ -1,6 +1,6 @@ #!/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 diff --git a/support/test/run_test_vim b/support/test/run_test_vim index 6d79b4b..beb27b2 100755 --- a/support/test/run_test_vim +++ b/support/test/run_test_vim @@ -1,8 +1,8 @@ #!/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 "$@" +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 c3f5978..a9043a6 100644 --- a/tests/breakpoints.test.vim +++ b/tests/breakpoints.test.vim @@ -156,6 +156,10 @@ function! Test_Use_Mappings_HUMAN() " Here we go. Start Debugging 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() @@ -166,7 +170,6 @@ function! Test_Use_Mappings_HUMAN() call assert_equal( 1, len( signs ), 1 ) call assert_equal( 0, len( signs[ 0 ].signs ) ) - lcd - %bwipeout! endfunction diff --git a/tests/run_test.vim b/tests/run_test.vim index 3cfae67..a5c0e80 100644 --- a/tests/run_test.vim +++ b/tests/run_test.vim @@ -115,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 @@ -197,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 @@ -318,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