Skip to content

Commit 7ac616c

Browse files
committed
patch 8.2.1438: missing tests for interrupting script execution from debugger
Problem: Missing tests for interrupting script execution from debugger. Solution: Add tests. (Yegappan Lakshmanan, closes #6697)
1 parent c9edd6b commit 7ac616c

2 files changed

Lines changed: 125 additions & 0 deletions

File tree

src/testdir/test_debugger.vim

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,4 +1020,127 @@ func Test_debug_backtrace_level()
10201020
call delete('Xtest2.vim')
10211021
endfunc
10221022

1023+
" Test for setting a breakpoint on a :endif where the :if condition is false
1024+
" and then quit the script. This should generate an interrupt.
1025+
func Test_breakpt_endif_intr()
1026+
func F()
1027+
let g:Xpath ..= 'a'
1028+
if v:false
1029+
let g:Xpath ..= 'b'
1030+
endif
1031+
invalid_command
1032+
endfunc
1033+
1034+
let g:Xpath = ''
1035+
breakadd func 4 F
1036+
try
1037+
let caught_intr = 0
1038+
debuggreedy
1039+
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1040+
call F()
1041+
catch /^Vim:Interrupt$/
1042+
call assert_match('\.F, line 4', v:throwpoint)
1043+
let caught_intr = 1
1044+
endtry
1045+
0debuggreedy
1046+
call assert_equal(1, caught_intr)
1047+
call assert_equal('a', g:Xpath)
1048+
breakdel *
1049+
delfunc F
1050+
endfunc
1051+
1052+
" Test for setting a breakpoint on a :else where the :if condition is false
1053+
" and then quit the script. This should generate an interrupt.
1054+
func Test_breakpt_else_intr()
1055+
func F()
1056+
let g:Xpath ..= 'a'
1057+
if v:false
1058+
let g:Xpath ..= 'b'
1059+
else
1060+
invalid_command
1061+
endif
1062+
invalid_command
1063+
endfunc
1064+
1065+
let g:Xpath = ''
1066+
breakadd func 4 F
1067+
try
1068+
let caught_intr = 0
1069+
debuggreedy
1070+
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1071+
call F()
1072+
catch /^Vim:Interrupt$/
1073+
call assert_match('\.F, line 4', v:throwpoint)
1074+
let caught_intr = 1
1075+
endtry
1076+
0debuggreedy
1077+
call assert_equal(1, caught_intr)
1078+
call assert_equal('a', g:Xpath)
1079+
breakdel *
1080+
delfunc F
1081+
endfunc
1082+
1083+
" Test for setting a breakpoint on a :endwhile where the :while condition is
1084+
" false and then quit the script. This should generate an interrupt.
1085+
func Test_breakpt_endwhile_intr()
1086+
func F()
1087+
let g:Xpath ..= 'a'
1088+
while v:false
1089+
let g:Xpath ..= 'b'
1090+
endwhile
1091+
invalid_command
1092+
endfunc
1093+
1094+
let g:Xpath = ''
1095+
breakadd func 4 F
1096+
try
1097+
let caught_intr = 0
1098+
debuggreedy
1099+
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1100+
call F()
1101+
catch /^Vim:Interrupt$/
1102+
call assert_match('\.F, line 4', v:throwpoint)
1103+
let caught_intr = 1
1104+
endtry
1105+
0debuggreedy
1106+
call assert_equal(1, caught_intr)
1107+
call assert_equal('a', g:Xpath)
1108+
breakdel *
1109+
delfunc F
1110+
endfunc
1111+
1112+
" Test for setting a breakpoint on an :endtry where an exception is pending to
1113+
" be processed and then quit the script. This should generate an interrupt and
1114+
" the thrown exception should be ignored.
1115+
func Test_breakpt_endtry_intr()
1116+
func F()
1117+
try
1118+
let g:Xpath ..= 'a'
1119+
throw "abc"
1120+
endtry
1121+
invalid_command
1122+
endfunc
1123+
1124+
let g:Xpath = ''
1125+
breakadd func 4 F
1126+
try
1127+
let caught_intr = 0
1128+
let caught_abc = 0
1129+
debuggreedy
1130+
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1131+
call F()
1132+
catch /abc/
1133+
let caught_abc = 1
1134+
catch /^Vim:Interrupt$/
1135+
call assert_match('\.F, line 4', v:throwpoint)
1136+
let caught_intr = 1
1137+
endtry
1138+
0debuggreedy
1139+
call assert_equal(1, caught_intr)
1140+
call assert_equal(0, caught_abc)
1141+
call assert_equal('a', g:Xpath)
1142+
breakdel *
1143+
delfunc F
1144+
endfunc
1145+
10231146
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1438,
757759
/**/
758760
1437,
759761
/**/

0 commit comments

Comments
 (0)