Add a bunch of tests for the ui customisation
This commit is contained in:
parent
ebc0b3607a
commit
727214c599
6 changed files with 354 additions and 13 deletions
|
|
@ -62,7 +62,7 @@ stages:
|
|||
displayName: 'Run the tests'
|
||||
env:
|
||||
VIMSPECTOR_MIMODE: gdb
|
||||
VIMSPECTOR_TEST_STDOUT: true
|
||||
VIMSPECTOR_TEST_STDOUT: all
|
||||
|
||||
- bash: ./make_package linux $(Build.SourceVersion)
|
||||
displayName: 'Package'
|
||||
|
|
@ -107,7 +107,7 @@ stages:
|
|||
displayName: 'Run the tests'
|
||||
env:
|
||||
VIMSPECTOR_MIMODE: lldb
|
||||
VIMSPECTOR_TEST_STDOUT: true
|
||||
VIMSPECTOR_TEST_STDOUT: all
|
||||
|
||||
- bash: ./make_package macos $(Build.SourceVersion)
|
||||
displayName: 'Package'
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function! s:RunTestUnderCursor()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' '
|
||||
execute s:make_cmd . ' --report messages '
|
||||
\ . get( g:, 'vimspector_test_args', '' ) . ' '
|
||||
\ . l:test_arg
|
||||
finally
|
||||
|
|
@ -105,7 +105,7 @@ function! s:RunTest()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' '
|
||||
execute s:make_cmd . ' --report messages '
|
||||
\ . get( g:, 'vimspector_test_args', '' )
|
||||
\ . ' %:p:t'
|
||||
finally
|
||||
|
|
@ -118,7 +118,7 @@ function! s:RunAllTests()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' '
|
||||
execute s:make_cmd . ' --report messages '
|
||||
\ . get( g:, 'vimspector_test_args', '' )
|
||||
finally
|
||||
execute 'lcd ' . l:cwd
|
||||
|
|
|
|||
|
|
@ -258,5 +258,8 @@ class CodeView( object ):
|
|||
else:
|
||||
self._terminal_window = terminal_window
|
||||
self._terminal_buffer_number = buffer_number
|
||||
vim.vars[ 'vimspector_session_windows' ][ 'terminal' ] = utils.WindowID(
|
||||
self._terminal_window,
|
||||
vim.current.tabpage )
|
||||
|
||||
return buffer_number
|
||||
|
|
|
|||
27
run_tests
27
run_tests
|
|
@ -3,8 +3,9 @@
|
|||
if [ "$1" == "--help" ]; then
|
||||
echo "$(basename $0) [--basedir <basedir>] [--install] <optional list of tests in form file:func>"
|
||||
echo ""
|
||||
echo " --basedir <basedir> path to runtime directory like the optino to install_gadget.py"
|
||||
echo " --install run install_gadget.py, useful with --basedir"
|
||||
echo " --basedir <basedir> path to runtime directory like the optino to install_gadget.py"
|
||||
echo " --install run install_gadget.py, useful with --basedir"
|
||||
echo " --report <messages|all> how verbose to be with stdout"
|
||||
echo "e.g.: "
|
||||
echo " - run all tests: $0"
|
||||
echo " - run specific tests script: $0 signature_help.test.vim"
|
||||
|
|
@ -23,19 +24,24 @@ BASEDIR_CMD='py3 pass'
|
|||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
"--basedir")
|
||||
BASEDIR=$2
|
||||
shift
|
||||
BASEDIR=$1
|
||||
shift
|
||||
if [[ ! $BASEDIR = /* ]]; then
|
||||
# Relative
|
||||
BASEDIR=$(pwd)/${BASEDIR}
|
||||
fi
|
||||
BASEDIR_CMD="let g:vimspector_base_dir='${BASEDIR}'"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
"--install")
|
||||
INSTALL=1
|
||||
shift
|
||||
;;
|
||||
"--report")
|
||||
shift
|
||||
VIMSPECTOR_TEST_STDOUT=$1
|
||||
shift
|
||||
;;
|
||||
"--")
|
||||
shift
|
||||
break
|
||||
|
|
@ -109,10 +115,16 @@ for t in ${TESTS}; do
|
|||
rm -rf $TESTLOGDIR
|
||||
mkdir -p $TESTLOGDIR
|
||||
${RUN_VIM} --version > ${TESTLOGDIR}/vimversion
|
||||
if [ "$VIMSPECTOR_TEST_STDOUT" = "messages" ]; then
|
||||
if [ -f messages ]; then
|
||||
cat messages
|
||||
fi
|
||||
fi
|
||||
|
||||
for l in messages debuglog test.log *.testlog; do
|
||||
# In CI we can't view the output files, so we just have to cat them
|
||||
if [ -f $l ]; then
|
||||
if [ "$VIMSPECTOR_TEST_STDOUT" ]; then
|
||||
if [ "$VIMSPECTOR_TEST_STDOUT" = "all" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "*** START: $l ***"
|
||||
|
|
@ -130,7 +142,6 @@ echo "Done running tests"
|
|||
popd > /dev/null
|
||||
|
||||
echo ""
|
||||
echo "All done."
|
||||
|
||||
echo "All done. Exit with ${RESULT}"
|
||||
|
||||
exit $RESULT
|
||||
|
|
|
|||
326
tests/ui.test.vim
Normal file
326
tests/ui.test.vim
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
let s:fn='main.py'
|
||||
|
||||
function! SetUp()
|
||||
call vimspector#test#setup#SetUpWithMappings( 'HUMAN' )
|
||||
endfunction
|
||||
|
||||
function! ClearDown()
|
||||
call vimspector#test#setup#ClearDown()
|
||||
endfunction
|
||||
|
||||
function! s:StartDebugging()
|
||||
lcd ../support/test/python/simple_python
|
||||
exe 'edit ' . s:fn
|
||||
call setpos( '.', [ 0, 23, 1 ] )
|
||||
call vimspector#ToggleBreakpoint()
|
||||
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 23, 1 )
|
||||
endfunction
|
||||
|
||||
function! Test_StandardLayout()
|
||||
call s:StartDebugging()
|
||||
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.variables ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.watches ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.stack_trace ],
|
||||
\ ] ],
|
||||
\ [ 'col', [
|
||||
\ [ 'row', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.output ],
|
||||
\ ] ]
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
||||
function! Test_CloseVariables()
|
||||
call s:StartDebugging()
|
||||
|
||||
call win_execute( g:vimspector_session_windows.variables, 'q' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.watches ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.stack_trace ],
|
||||
\ ] ],
|
||||
\ [ 'col', [
|
||||
\ [ 'row', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.output ],
|
||||
\ ] ]
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
||||
function! Test_CloseWatches()
|
||||
call s:StartDebugging()
|
||||
|
||||
call win_execute( g:vimspector_session_windows.watches, 'q' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
" Add a wtch
|
||||
call vimspector#AddWatch( 't' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 26, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.variables ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.stack_trace ],
|
||||
\ ] ],
|
||||
\ [ 'col', [
|
||||
\ [ 'row', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.output ],
|
||||
\ ] ]
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
" Replace the variables view with a watches view!
|
||||
call win_execute( g:vimspector_session_windows.variables,
|
||||
\ 'bu vimspector.Watches' )
|
||||
|
||||
" Delete a watch expression
|
||||
call win_gotoid( g:vimspector_session_windows.variables )
|
||||
call setpos( '.', [ 0, 3, 1 ] )
|
||||
call feedkeys( "\<Del>", 'xt' )
|
||||
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
|
||||
call vimspector#StepInto()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 13, 1 )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 14, 1 )
|
||||
call vimspector#AddWatch( 'i' )
|
||||
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i',
|
||||
\ ' *- Result: 0',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
call vimspector#AddWatch( 'i+1' )
|
||||
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i',
|
||||
\ ' - Result: 0',
|
||||
\ 'Expression: i+1',
|
||||
\ ' *- Result: 1',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
call vimspector#AddWatch( 'i+2' )
|
||||
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i',
|
||||
\ ' - Result: 0',
|
||||
\ 'Expression: i+1',
|
||||
\ ' - Result: 1',
|
||||
\ 'Expression: i+2',
|
||||
\ ' *- Result: 2',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
" Delete that middle watch
|
||||
call win_gotoid( g:vimspector_session_windows.variables )
|
||||
call setpos( '.', [ 0, 4, 1 ] )
|
||||
call vimspector#DeleteWatch()
|
||||
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i',
|
||||
\ ' - Result: 0',
|
||||
\ 'Expression: i+2',
|
||||
\ ' *- Result: 2',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 15, 1 )
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i',
|
||||
\ ' - Result: 0',
|
||||
\ 'Expression: i+2',
|
||||
\ ' - Result: 2',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
|
||||
" Delete the top watch
|
||||
call win_gotoid( g:vimspector_session_windows.variables )
|
||||
call setpos( '.', [ 0, 3, 1 ] )
|
||||
call vimspector#DeleteWatch()
|
||||
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 13, 1 )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 14, 1 )
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal(
|
||||
\ [
|
||||
\ 'Watches: ----',
|
||||
\ 'Expression: i+2',
|
||||
\ ' *- Result: 3',
|
||||
\ ],
|
||||
\ getbufline( winbufnr( g:vimspector_session_windows.variables ),
|
||||
\ 1,
|
||||
\ '$' )
|
||||
\ )
|
||||
\ } )
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
||||
function! Test_CloseStackTrace()
|
||||
call s:StartDebugging()
|
||||
|
||||
call win_execute( g:vimspector_session_windows.stack_trace, 'q' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.variables ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.watches ],
|
||||
\ ] ],
|
||||
\ [ 'col', [
|
||||
\ [ 'row', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.output ],
|
||||
\ ] ]
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
||||
function! Test_CloseOutput()
|
||||
call s:StartDebugging()
|
||||
|
||||
call win_execute( g:vimspector_session_windows.output, 'q' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.variables ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.watches ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.stack_trace ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
||||
function! Test_CustomUI()
|
||||
augroup TestCustomUI
|
||||
au!
|
||||
au User VimspectorUICreated
|
||||
\ call win_execute( g:vimspector_session_windows.watches, 'q' )
|
||||
augroup END
|
||||
|
||||
call s:StartDebugging()
|
||||
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 25, 1 )
|
||||
|
||||
" Add a watch
|
||||
call vimspector#AddWatch( 't' )
|
||||
call vimspector#StepOver()
|
||||
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 26, 1 )
|
||||
|
||||
call assert_equal(
|
||||
\ [ 'row', [
|
||||
\ [ 'col', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.variables ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.stack_trace ],
|
||||
\ ] ],
|
||||
\ [ 'col', [
|
||||
\ [ 'row', [
|
||||
\ [ 'leaf', g:vimspector_session_windows.code ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.terminal ],
|
||||
\ ] ],
|
||||
\ [ 'leaf', g:vimspector_session_windows.output ],
|
||||
\ ] ]
|
||||
\ ] ],
|
||||
\ winlayout( g:vimspector_session_windows.tabpage ) )
|
||||
|
||||
au! TestCustomUI
|
||||
call vimspector#test#setup#Reset()
|
||||
%bwipe!
|
||||
endfunction
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
let g:vimspector_test_plugin_path = expand( '<sfile>:p:h:h' )
|
||||
set mouse=a
|
||||
set noequalalways
|
||||
|
||||
let &rtp = &rtp . ',' . g:vimspector_test_plugin_path
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue