0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.1.1180: Vim script debugger tests are old style

Problem:    Vim script debugger tests are old style.
Solution:   Turn into new style tests. (Yegappan Lakshmanan, closes #4259)
This commit is contained in:
Bram Moolenaar
2019-04-17 16:54:05 +02:00
parent 696d637728
commit 113bf0672b
7 changed files with 238 additions and 173 deletions

View File

@@ -2176,7 +2176,7 @@ test1 \
test64 test69 \
test70 test72 \
test86 test87 test88 \
test94 test95 test99 test108:
test94 test95 test99:
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.

View File

@@ -28,7 +28,6 @@ SCRIPTS_ALL = \
test94.out \
test95.out \
test99.out \
test108.out \
test_eval.out
@@ -97,6 +96,7 @@ NEW_TESTS = \
test_cscope \
test_cursor_func \
test_curswant \
test_debugger \
test_delete \
test_diffmode \
test_digraph \
@@ -312,6 +312,7 @@ NEW_TESTS_RES = \
test_crypt.res \
test_cscope.res \
test_curswant.res \
test_debugger.res \
test_diffmode.res \
test_digraph.res \
test_display.res \

View File

@@ -80,7 +80,7 @@ SCRIPT = test1.out test3.out \
test42.out test44.out test48.out test49.out \
test64.out test69.out \
test72.out test77a.out test88.out \
test94.out test95.out test99.out test108.out \
test94.out test95.out test99.out \
test_eval.out
# Known problems:

View File

@@ -1,88 +0,0 @@
Tests for backtrace debug commands. vim: set ft=vim :
STARTTEST
:so small.vim
:lang mess C
:function! Foo()
: let var1 = 1
: let var2 = Bar(var1) + 9
: return var2
:endfunction
:
:function! Bar(var)
: let var1 = 2 + a:var
: let var2 = Bazz(var1) + 4
: return var2
:endfunction
:
:function! Bazz(var)
: let var1 = 3 + a:var
: let var3 = "another var"
: return var1
:endfunction
:new
:debuggreedy
:redir => out
:debug echo Foo()
step
step
step
step
step
step
echo "- show backtrace:\n"
backtrace
echo "\nshow variables on different levels:\n"
echo var1
up
back
echo var1
u
bt
echo var1
echo "\n- undefined vars:\n"
step
frame 2
echo "undefined var3 on former level:"
echo var3
fr 0
echo "here var3 is defined with \"another var\":"
echo var3
step
step
step
up
echo "\nundefined var2 on former level"
echo var2
down
echo "here var2 is defined with 10:"
echo var2
echo "\n- backtrace movements:\n"
b
echo "\nnext command cannot go down, we are on bottom\n"
down
up
echo "\nnext command cannot go up, we are on top\n"
up
b
echo "fil is not frame or finish, it is file"
fil
echo "\n- relative backtrace movement\n"
fr -1
frame
fra +1
fram
echo "\n- go beyond limits does not crash\n"
fr 100
fra
frame -40
fram
echo "\n- final result 19:"
cont
:0debuggreedy
:redir END
:$put =out
:w! test.out
:qa!
ENDTEST

View File

@@ -1,82 +0,0 @@
- show backtrace:
2 function Foo[2]
1 Bar[2]
->0 Bazz
line 2: let var3 = "another var"
show variables on different levels:
6
2 function Foo[2]
->1 Bar[2]
0 Bazz
line 2: let var3 = "another var"
3
->2 function Foo[2]
1 Bar[2]
0 Bazz
line 2: let var3 = "another var"
1
- undefined vars:
undefined var3 on former level:
Error detected while processing function Foo[2]..Bar[2]..Bazz:
line 3:
E121: Undefined variable: var3
here var3 is defined with "another var":
another var
undefined var2 on former level
Error detected while processing function Foo[2]..Bar:
line 3:
E121: Undefined variable: var2
here var2 is defined with 10:
10
- backtrace movements:
1 function Foo[2]
->0 Bar
line 3: End of function
next command cannot go down, we are on bottom
frame is zero
next command cannot go up, we are on top
frame at highest level: 1
->1 function Foo[2]
0 Bar
line 3: End of function
fil is not frame or finish, it is file
"[No Name]" --No lines in buffer--
- relative backtrace movement
1 function Foo[2]
->0 Bar
line 3: End of function
->1 function Foo[2]
0 Bar
line 3: End of function
- go beyond limits does not crash
frame at highest level: 1
->1 function Foo[2]
0 Bar
line 3: End of function
frame is zero
1 function Foo[2]
->0 Bar
line 3: End of function
- final result 19:
19

View File

@@ -0,0 +1,232 @@
" Tests for the Vim script debug commands
source shared.vim
source screendump.vim
" Run a Vim debugger command
" If the expected output argument is supplied, then check for it.
func RunDbgCmd(buf, cmd, ...)
call term_sendkeys(a:buf, a:cmd . "\r")
call term_wait(a:buf)
if a:0 != 0
" Verify the expected output
let lnum = 20 - len(a:1)
for l in a:1
call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))})
let lnum += 1
endfor
endif
endfunc
" Debugger tests
func Test_Debugger()
if !CanRunVimInTerminal()
return
endif
" Create a Vim script with some functions
call writefile([
\ 'func Foo()',
\ ' let var1 = 1',
\ ' let var2 = Bar(var1) + 9',
\ ' return var2',
\ 'endfunc',
\ 'func Bar(var)',
\ ' let var1 = 2 + a:var',
\ ' let var2 = Bazz(var1) + 4',
\ ' return var2',
\ 'endfunc',
\ 'func Bazz(var)',
\ ' let var1 = 3 + a:var',
\ ' let var3 = "another var"',
\ ' let var3 = "value2"',
\ ' let var3 = "value3"',
\ ' return var1',
\ 'endfunc'], 'Xtest.vim')
" Start Vim in a terminal
let buf = RunVimInTerminal('-S Xtest.vim', {})
" Start the Vim debugger
call RunDbgCmd(buf, ':debug echo Foo()')
" Create a few stack frames by stepping through functions
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
" check backtrace
call RunDbgCmd(buf, 'backtrace', [
\ ' 2 function Foo[2]',
\ ' 1 Bar[2]',
\ '->0 Bazz',
\ 'line 2: let var3 = "another var"'])
" Check variables in different stack frames
call RunDbgCmd(buf, 'echo var1', ['6'])
call RunDbgCmd(buf, 'up')
call RunDbgCmd(buf, 'back', [
\ ' 2 function Foo[2]',
\ '->1 Bar[2]',
\ ' 0 Bazz',
\ 'line 2: let var3 = "another var"'])
call RunDbgCmd(buf, 'echo var1', ['3'])
call RunDbgCmd(buf, 'u')
call RunDbgCmd(buf, 'bt', [
\ '->2 function Foo[2]',
\ ' 1 Bar[2]',
\ ' 0 Bazz',
\ 'line 2: let var3 = "another var"'])
call RunDbgCmd(buf, 'echo var1', ['1'])
" Undefined variables
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'frame 2')
call RunDbgCmd(buf, 'echo var3', [
\ 'Error detected while processing function Foo[2]..Bar[2]..Bazz:',
\ 'line 3:',
\ 'E121: Undefined variable: var3'])
" var3 is defined in this level with some other value
call RunDbgCmd(buf, 'fr 0')
call RunDbgCmd(buf, 'echo var3', ['another var'])
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'step', [
\ 'function Foo[2]..Bar',
\ 'line 3: End of function'])
call RunDbgCmd(buf, 'up')
" Undefined var2
call RunDbgCmd(buf, 'echo var2', [
\ 'Error detected while processing function Foo[2]..Bar:',
\ 'line 3:',
\ 'E121: Undefined variable: var2'])
" Var2 is defined with 10
call RunDbgCmd(buf, 'down')
call RunDbgCmd(buf, 'echo var2', ['10'])
" Backtrace movements
call RunDbgCmd(buf, 'b', [
\ ' 1 function Foo[2]',
\ '->0 Bar',
\ 'line 3: End of function'])
" next command cannot go down, we are on bottom
call RunDbgCmd(buf, 'down', ['frame is zero'])
call RunDbgCmd(buf, 'up')
" next command cannot go up, we are on top
call RunDbgCmd(buf, 'up', ['frame at highest level: 1'])
call RunDbgCmd(buf, 'where', [
\ '->1 function Foo[2]',
\ ' 0 Bar',
\ 'line 3: End of function'])
" fil is not frame or finish, it is file
call RunDbgCmd(buf, 'fil', ['"[No Name]" --No lines in buffer--'])
" relative backtrace movement
call RunDbgCmd(buf, 'fr -1')
call RunDbgCmd(buf, 'frame', [
\ ' 1 function Foo[2]',
\ '->0 Bar',
\ 'line 3: End of function'])
call RunDbgCmd(buf, 'fr +1')
call RunDbgCmd(buf, 'fram', [
\ '->1 function Foo[2]',
\ ' 0 Bar',
\ 'line 3: End of function'])
" go beyond limits does not crash
call RunDbgCmd(buf, 'fr 100', ['frame at highest level: 1'])
call RunDbgCmd(buf, 'fra', [
\ '->1 function Foo[2]',
\ ' 0 Bar',
\ 'line 3: End of function'])
call RunDbgCmd(buf, 'frame -40', ['frame is zero'])
call RunDbgCmd(buf, 'fram', [
\ ' 1 function Foo[2]',
\ '->0 Bar',
\ 'line 3: End of function'])
" final result 19
call RunDbgCmd(buf, 'cont', ['19'])
" breakpoints tests
" Start a debug session, so that reading the last line from the terminal
" works properly.
call RunDbgCmd(buf, ':debug echo Foo()')
" No breakpoints
call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
" Place some breakpoints
call RunDbgCmd(buf, 'breaka func Bar')
call RunDbgCmd(buf, 'breaklis', [' 1 func Bar line 1'])
call RunDbgCmd(buf, 'breakadd func 3 Bazz')
call RunDbgCmd(buf, 'breaklist', [' 1 func Bar line 1',
\ ' 2 func Bazz line 3'])
" Check whether the breakpoints are hit
call RunDbgCmd(buf, 'cont', [
\ 'Breakpoint in "Bar" line 1',
\ 'function Foo[2]..Bar',
\ 'line 1: let var1 = 2 + a:var'])
call RunDbgCmd(buf, 'cont', [
\ 'Breakpoint in "Bazz" line 3',
\ 'function Foo[2]..Bar[2]..Bazz',
\ 'line 3: let var3 = "value2"'])
" Delete the breakpoints
call RunDbgCmd(buf, 'breakd 1')
call RunDbgCmd(buf, 'breakli', [' 2 func Bazz line 3'])
call RunDbgCmd(buf, 'breakdel func 3 Bazz')
call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
call RunDbgCmd(buf, 'cont')
" Make sure the breakpoints are removed
call RunDbgCmd(buf, ':echo Foo()', ['19'])
" Delete a non-existing breakpoint
call RunDbgCmd(buf, ':breakdel 2', ['E161: Breakpoint not found: 2'])
" Expression breakpoint
call RunDbgCmd(buf, ':breakadd func 2 Bazz')
call RunDbgCmd(buf, ':echo Bazz(1)')
call RunDbgCmd(buf, 'step')
call RunDbgCmd(buf, 'breaka expr var3')
call RunDbgCmd(buf, 'breakl', [' 4 expr var3'])
call RunDbgCmd(buf, 'cont', ['Breakpoint in "Bazz" line 4',
\ 'Oldval = "''another var''"',
\ 'Newval = "''value2''"',
\ 'function Bazz',
\ 'line 4: let var3 = "value3"'])
call RunDbgCmd(buf, 'breakdel *')
call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
" finish the current function
call RunDbgCmd(buf, 'finish', [
\ 'function Bazz',
\ 'line 5: End of function'])
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
call delete('Xtest.vim')
endfunc

View File

@@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1180,
/**/
1179,
/**/