Patch 8.1.1180
Problem: Vim script debugger tests are old style.
Solution: Turn into new style tests. (Yegappan Lakshmanan, closes #4259)
Files: src/Makefile, src/testdir/Make_all.mak, src/testdir/Make_vms.mms,
src/testdir/test108.in, src/testdir/test108.ok,
src/testdir/test_debugger.vim
*** ../vim-8.1.1179/src/Makefile 2019-04-11 18:13:53.337894322 +0200
--- src/Makefile 2019-04-17 16:49:23.358684152 +0200
***************
*** 2176,2182 ****
test64 test69 \
test70 test72 \
test86 test87 test88 \
! test94 test95 test99 test108:
cd testdir; rm -f [email protected]; $(MAKE) -f Makefile [email protected]
VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.
--- 2176,2182 ----
test64 test69 \
test70 test72 \
test86 test87 test88 \
! test94 test95 test99:
cd testdir; rm -f [email protected]; $(MAKE) -f Makefile [email protected]
VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.
*** ../vim-8.1.1179/src/testdir/Make_all.mak 2019-04-07 14:21:26.226339351
+0200
--- src/testdir/Make_all.mak 2019-04-17 16:49:23.358684152 +0200
***************
*** 28,34 ****
test94.out \
test95.out \
test99.out \
- test108.out \
test_eval.out
--- 28,33 ----
***************
*** 97,102 ****
--- 96,102 ----
test_cscope \
test_cursor_func \
test_curswant \
+ test_debugger \
test_delete \
test_diffmode \
test_digraph \
***************
*** 312,317 ****
--- 312,318 ----
test_crypt.res \
test_cscope.res \
test_curswant.res \
+ test_debugger.res \
test_diffmode.res \
test_digraph.res \
test_display.res \
*** ../vim-8.1.1179/src/testdir/Make_vms.mms 2018-07-14 21:48:42.444978086
+0200
--- src/testdir/Make_vms.mms 2019-04-17 16:49:23.358684152 +0200
***************
*** 80,86 ****
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 \
test_eval.out
# Known problems:
--- 80,86 ----
test42.out test44.out test48.out test49.out \
test64.out test69.out \
test72.out test77a.out test88.out \
! test94.out test95.out test99.out \
test_eval.out
# Known problems:
*** ../vim-8.1.1179/src/testdir/test108.in 2016-01-16 22:06:08.000000000
+0100
--- src/testdir/test108.in 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,88 ****
- 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
-
--- 0 ----
*** ../vim-8.1.1179/src/testdir/test108.ok 2018-11-28 20:38:34.564273386
+0100
--- src/testdir/test108.ok 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,82 ****
-
-
-
- - 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
-
--- 0 ----
*** ../vim-8.1.1179/src/testdir/test_debugger.vim 2019-04-17
16:52:46.237656050 +0200
--- src/testdir/test_debugger.vim 2019-04-17 16:51:44.169971069 +0200
***************
*** 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
*** ../vim-8.1.1179/src/version.c 2019-04-17 16:33:42.795349446 +0200
--- src/version.c 2019-04-17 16:50:55.034220168 +0200
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1180,
/**/
--
FIRST HEAD: Oh! quick! get the sword out I want to cut his head off.
THIRD HEAD: Oh, cut your own head off.
SECOND HEAD: Yes - do us all a favour.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.