Merge pull request #21 from puremourning/test-clear-breakpoints
Test clear breakpoints
This commit is contained in:
commit
4a42ccb802
7 changed files with 77 additions and 32 deletions
|
|
@ -205,11 +205,11 @@ class DebugSession( object ):
|
||||||
|
|
||||||
def _Reset( self ):
|
def _Reset( self ):
|
||||||
if self._uiTab:
|
if self._uiTab:
|
||||||
|
vim.current.tabpage = self._uiTab
|
||||||
self._stackTraceView.Reset()
|
self._stackTraceView.Reset()
|
||||||
self._variablesView.Reset()
|
self._variablesView.Reset()
|
||||||
self._outputView.Reset()
|
self._outputView.Reset()
|
||||||
self._codeView.Reset()
|
self._codeView.Reset()
|
||||||
vim.current.tabpage = self._uiTab
|
|
||||||
vim.command( 'tabclose!' )
|
vim.command( 'tabclose!' )
|
||||||
self._uiTab = None
|
self._uiTab = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 "$@"
|
|
||||||
28
run_tests
28
run_tests
|
|
@ -1,8 +1,21 @@
|
||||||
#!/usr/bin/env bash
|
#!/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"
|
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..."
|
echo "%SETUP - Building test programs..."
|
||||||
set -e
|
set -e
|
||||||
pushd tests/testdata/cpp/simple
|
pushd tests/testdata/cpp/simple
|
||||||
|
|
@ -17,12 +30,21 @@ echo "Running Vimspector Vim tests"
|
||||||
|
|
||||||
RESULT=0
|
RESULT=0
|
||||||
|
|
||||||
for t in *.test.vim; do
|
TESTS="$@"
|
||||||
|
|
||||||
|
if [ -z "$TESTS" ]; then
|
||||||
|
TESTS=*.test.vim
|
||||||
|
fi
|
||||||
|
|
||||||
|
for t in ${TESTS}; do
|
||||||
echo ""
|
echo ""
|
||||||
echo "%RUN: $t"
|
echo "%RUN: $t"
|
||||||
rm -f messages debuglog
|
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"
|
echo "%PASS: $t PASSED"
|
||||||
else
|
else
|
||||||
cat messages
|
cat messages
|
||||||
|
|
|
||||||
8
support/test/run_test_vim
Executable file
8
support/test/run_test_vim
Executable file
|
|
@ -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 \
|
||||||
|
"$@"
|
||||||
|
|
@ -54,14 +54,14 @@ endfunction
|
||||||
function! Test_Signs_Placed_Using_API_Are_Shown()
|
function! Test_Signs_Placed_Using_API_Are_Shown()
|
||||||
" We need a real file
|
" We need a real file
|
||||||
edit testdata/cpp/simple/simple.cpp
|
edit testdata/cpp/simple/simple.cpp
|
||||||
call feedkeys( "/printf\<CR>", 'x' )
|
call feedkeys( "/printf\<CR>", 'xt' )
|
||||||
|
|
||||||
" Set breakpoint
|
" Set breakpoint
|
||||||
call vimspector#ToggleBreakpoint()
|
call vimspector#ToggleBreakpoint()
|
||||||
|
|
||||||
call assert_true( exists( '*vimspector#ToggleBreakpoint' ) )
|
call assert_true( exists( '*vimspector#ToggleBreakpoint' ) )
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -73,7 +73,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown()
|
||||||
" Disable breakpoint
|
" Disable breakpoint
|
||||||
call vimspector#ToggleBreakpoint()
|
call vimspector#ToggleBreakpoint()
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -85,7 +85,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown()
|
||||||
" Remove breakpoint
|
" Remove breakpoint
|
||||||
call vimspector#ToggleBreakpoint()
|
call vimspector#ToggleBreakpoint()
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -94,7 +94,7 @@ function! Test_Signs_Placed_Using_API_Are_Shown()
|
||||||
call assert_equal( 0, len( signs[ 0 ].signs ) )
|
call assert_equal( 0, len( signs[ 0 ].signs ) )
|
||||||
|
|
||||||
call vimspector#ClearBreakpoints()
|
call vimspector#ClearBreakpoints()
|
||||||
bwipeout!
|
%bwipeout!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUp_Test_Use_Mappings_HUMAN()
|
function! SetUp_Test_Use_Mappings_HUMAN()
|
||||||
|
|
@ -109,9 +109,9 @@ function! Test_Use_Mappings_HUMAN()
|
||||||
call assert_equal( 15, line( '.' ) )
|
call assert_equal( 15, line( '.' ) )
|
||||||
|
|
||||||
" Add the breakpoing
|
" Add the breakpoing
|
||||||
call feedkeys( "\<F9>", 'x' )
|
call feedkeys( "\<F9>", 'xt' )
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -121,9 +121,9 @@ function! Test_Use_Mappings_HUMAN()
|
||||||
call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name )
|
call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name )
|
||||||
|
|
||||||
" Disable the breakpoint
|
" Disable the breakpoint
|
||||||
call feedkeys( "\<F9>", 'x' )
|
call feedkeys( "\<F9>", 'xt' )
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -132,9 +132,9 @@ function! Test_Use_Mappings_HUMAN()
|
||||||
call assert_equal( 'vimspectorBPDisabled', signs[ 0 ].signs[ 0 ].name )
|
call assert_equal( 'vimspectorBPDisabled', signs[ 0 ].signs[ 0 ].name )
|
||||||
|
|
||||||
" Delete the breakpoint
|
" Delete the breakpoint
|
||||||
call feedkeys( "\<F9>", 'x' )
|
call feedkeys( "\<F9>", 'xt' )
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -142,9 +142,9 @@ function! Test_Use_Mappings_HUMAN()
|
||||||
call assert_equal( 0, len( signs[ 0 ].signs ) )
|
call assert_equal( 0, len( signs[ 0 ].signs ) )
|
||||||
|
|
||||||
" Add it again
|
" Add it again
|
||||||
call feedkeys( "\<F9>", 'x' )
|
call feedkeys( "\<F9>", 'xt' )
|
||||||
|
|
||||||
let signs = sign_getplaced( '.', {
|
let signs = sign_getplaced( '%', {
|
||||||
\ 'group': 'VimspectorBP',
|
\ 'group': 'VimspectorBP',
|
||||||
\ 'line': line( '.' )
|
\ 'line': line( '.' )
|
||||||
\ } )
|
\ } )
|
||||||
|
|
@ -154,12 +154,22 @@ function! Test_Use_Mappings_HUMAN()
|
||||||
call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name )
|
call assert_equal( 'vimspectorBP', signs[ 0 ].signs[ 0 ].name )
|
||||||
|
|
||||||
" Here we go. Start Debugging
|
" Here we go. Start Debugging
|
||||||
call feedkeys( "\<F5>", 'x' )
|
call feedkeys( "\<F5>", '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#Reset()
|
||||||
|
|
||||||
call vimspector#ClearBreakpoints()
|
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 -
|
lcd -
|
||||||
bwipeout!
|
%bwipeout!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ func RunTheTest(test)
|
||||||
\ . ': '
|
\ . ': '
|
||||||
\ . v:exception
|
\ . v:exception
|
||||||
\ . ' @ '
|
\ . ' @ '
|
||||||
|
\ . g:testpath
|
||||||
|
\ . ':'
|
||||||
\ . v:throwpoint)
|
\ . v:throwpoint)
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
@ -97,6 +99,8 @@ func RunTheTest(test)
|
||||||
\ . ': '
|
\ . ': '
|
||||||
\ . v:exception
|
\ . v:exception
|
||||||
\ . ' @ '
|
\ . ' @ '
|
||||||
|
\ . g:testpath
|
||||||
|
\ . ':'
|
||||||
\ . v:throwpoint)
|
\ . v:throwpoint)
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
@ -111,6 +115,7 @@ func RunTheTest(test)
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
let s:test = a:test
|
let s:test = a:test
|
||||||
|
let s:testid = g:testpath . ':' . a:test
|
||||||
au VimLeavePre * call EarlyExit(s:test)
|
au VimLeavePre * call EarlyExit(s:test)
|
||||||
exe 'call ' . a:test
|
exe 'call ' . a:test
|
||||||
au! VimLeavePre
|
au! VimLeavePre
|
||||||
|
|
@ -126,6 +131,8 @@ func RunTheTest(test)
|
||||||
\ . ': '
|
\ . ': '
|
||||||
\ . v:exception
|
\ . v:exception
|
||||||
\ . ' @ '
|
\ . ' @ '
|
||||||
|
\ . g:testpath
|
||||||
|
\ . ':'
|
||||||
\ . v:throwpoint)
|
\ . v:throwpoint)
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
@ -143,6 +150,8 @@ func RunTheTest(test)
|
||||||
\ . ': '
|
\ . ': '
|
||||||
\ . v:exception
|
\ . v:exception
|
||||||
\ . ' @ '
|
\ . ' @ '
|
||||||
|
\ . g:testpath
|
||||||
|
\ . ':'
|
||||||
\ . v:throwpoint)
|
\ . v:throwpoint)
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
@ -156,6 +165,8 @@ func RunTheTest(test)
|
||||||
\ . ': '
|
\ . ': '
|
||||||
\ . v:exception
|
\ . v:exception
|
||||||
\ . ' @ '
|
\ . ' @ '
|
||||||
|
\ . g:testpath
|
||||||
|
\ . ':'
|
||||||
\ . v:throwpoint)
|
\ . v:throwpoint)
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
|
|
@ -187,7 +198,7 @@ endfunc
|
||||||
func AfterTheTest()
|
func AfterTheTest()
|
||||||
if len(v:errors) > 0
|
if len(v:errors) > 0
|
||||||
let s:fail += 1
|
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)
|
call extend(s:errors, v:errors)
|
||||||
let v:errors = []
|
let v:errors = []
|
||||||
endif
|
endif
|
||||||
|
|
@ -219,7 +230,7 @@ func FinishTesting()
|
||||||
" Append errors to test.log
|
" Append errors to test.log
|
||||||
split test.log
|
split test.log
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
call append(line('$'), 'From ' . g:testname . ':')
|
call append(line('$'), 'From ' . g:testpath . ':')
|
||||||
call append(line('$'), s:errors)
|
call append(line('$'), s:errors)
|
||||||
write
|
write
|
||||||
endif
|
endif
|
||||||
|
|
@ -244,7 +255,7 @@ func FinishTesting()
|
||||||
" Append messages to the file "messages"
|
" Append messages to the file "messages"
|
||||||
split messages
|
split messages
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
call append(line('$'), 'From ' . g:testname . ':')
|
call append(line('$'), 'From ' . g:testpath . ':')
|
||||||
call append(line('$'), s:messages)
|
call append(line('$'), s:messages)
|
||||||
write
|
write
|
||||||
|
|
||||||
|
|
@ -258,6 +269,7 @@ endfunc
|
||||||
" Source the test script. First grab the file name, in case the script
|
" Source the test script. First grab the file name, in case the script
|
||||||
" navigates away. g:testname can be used by the tests.
|
" navigates away. g:testname can be used by the tests.
|
||||||
let g:testname = expand('%')
|
let g:testname = expand('%')
|
||||||
|
let g:testpath = expand('%:p')
|
||||||
let s:done = 0
|
let s:done = 0
|
||||||
let s:fail = 0
|
let s:fail = 0
|
||||||
let s:errors = []
|
let s:errors = []
|
||||||
|
|
@ -307,7 +319,7 @@ for s:test in sort(s:tests)
|
||||||
\ && (index(s:flaky_tests, s:test) >= 0
|
\ && (index(s:flaky_tests, s:test) >= 0
|
||||||
\ || v:errors[0] =~ s:flaky_errors_re)
|
\ || v:errors[0] =~ s:flaky_errors_re)
|
||||||
while 1
|
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 extend(s:messages, v:errors)
|
||||||
|
|
||||||
call add(total_errors, 'Run ' . run_nr . ':')
|
call add(total_errors, 'Run ' . run_nr . ':')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
let g:vimspector_test_plugin_path = expand( '<sfile>:h:h' )
|
let g:vimspector_test_plugin_path = expand( '<sfile>:p:h:h' )
|
||||||
|
set mouse=a
|
||||||
|
|
||||||
let &rtp = &rtp . ',' . g:vimspector_test_plugin_path
|
let &rtp = &rtp . ',' . g:vimspector_test_plugin_path
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue