From 8d3dbf274675d8746cb1cafa446ebce88a5de54b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 06:46:12 +0800 Subject: vim-patch:9.0.1791: No tests for the termdebug plugin Problem: No tests for the termdebug plugin Solution: Add some simple tests for the termdebug plugin closes: vim/vim#12927 https://github.com/vim/vim/commit/58f39d89a8adff51ab04893d1fd28e3767979f9f Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_termdebug.vim | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 test/old/testdir/test_termdebug.vim (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim new file mode 100644 index 0000000000..4dca1a20fa --- /dev/null +++ b/test/old/testdir/test_termdebug.vim @@ -0,0 +1,91 @@ +" Test for the termdebug plugin + +source check.vim + +CheckUnix +" CheckFeature terminal +CheckExecutable gdb +CheckExecutable gcc + +let g:GDB = exepath('gdb') +if g:GDB->empty() + throw 'Skpped: gdb is not found in $PATH' +endif + +let g:GCC = exepath('gcc') +if g:GCC->empty() + throw 'Skpped: gcc is not found in $PATH' +endif + +packadd termdebug + +func Test_termdebug_basic() + let lines =<< trim END + #include + #include + + int isprime(int n) + { + if (n <= 1) + return 0; + + for (int i = 2; i <= n / 2; i++) + if (n % i == 0) + return 0; + + return 1; + } + + int main(int argc, char *argv[]) + { + int n = 7; + + printf("%d is %s prime\n", n, isprime(n) ? "a" : "not a"); + + return 0; + } + END + call writefile(lines, 'XTD_basic.c', 'D') + call system($'{g:GCC} -g -o XTD_basic XTD_basic.c') + + edit XTD_basic.c + Termdebug ./XTD_basic + call assert_equal(3, winnr('$')) + let gdb_buf = winbufnr(1) + wincmd b + Break 9 + call Nterm_wait(gdb_buf) + redraw! + call assert_equal([ + \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0', + \ 'priority': 110, 'group': 'TermDebug'}], + \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) + Run + call Nterm_wait(gdb_buf, 200) + redraw! + call assert_equal([ + \ {'lnum': 9, 'id': 12, 'name': 'debugPC', 'priority': 110, + \ 'group': 'TermDebug'}, + \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0', + \ 'priority': 110, 'group': 'TermDebug'}], + \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) + Finish + call Nterm_wait(gdb_buf) + redraw! + call assert_equal([ + \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0', + \ 'priority': 110, 'group': 'TermDebug'}, + \ {'lnum': 20, 'id': 12, 'name': 'debugPC', + \ 'priority': 110, 'group': 'TermDebug'}], + \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) + Continue + wincmd t + quit! + redraw! + call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs) + + call delete('XTD_basic') + %bw! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From c9e7e94fcc2e78af4c5c14cb38dfb3c36b6e2dd3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 06:53:08 +0800 Subject: vim-patch:9.0.1808: termdebug: Typo in termdebug test Problem: termdebug: Typo in termdebug test Solution: fix the typos https://github.com/vim/vim/commit/f2534434c99a2b0cea08b238df24979b3fdc9212 Co-authored-by: Christian Brabandt --- test/old/testdir/test_termdebug.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index 4dca1a20fa..656207cbda 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -9,12 +9,12 @@ CheckExecutable gcc let g:GDB = exepath('gdb') if g:GDB->empty() - throw 'Skpped: gdb is not found in $PATH' + throw 'Skipped: gdb is not found in $PATH' endif let g:GCC = exepath('gcc') if g:GCC->empty() - throw 'Skpped: gcc is not found in $PATH' + throw 'Skipped: gcc is not found in $PATH' endif packadd termdebug -- cgit From 4d36892191d01718f1549b99c7600a7694c38dab Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 06:53:25 +0800 Subject: vim-patch:9.0.1809: termdebug test flayk Problem: termdebug test flayk Solution: wait slightly longer https://github.com/vim/vim/commit/6c93c949298c1a6cb294a09b10d690cae357a8bf Co-authored-by: Christian Brabandt --- test/old/testdir/test_termdebug.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index 656207cbda..6b6140c8cb 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -61,7 +61,7 @@ func Test_termdebug_basic() \ 'priority': 110, 'group': 'TermDebug'}], \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) Run - call Nterm_wait(gdb_buf, 200) + call Nterm_wait(gdb_buf, 400) redraw! call assert_equal([ \ {'lnum': 9, 'id': 12, 'name': 'debugPC', 'priority': 110, -- cgit From 7b921c550191b300f0fa3ed5069e85fdd88ee959 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 06:59:36 +0800 Subject: vim-patch:9.0.1811: still some issues with term_debug test Problem: still some issues with term_debug test Solution: Use WaitForAssert() closes: vim/vim#12936 https://github.com/vim/vim/commit/85c3a5bc265393c1b8b93d8b88b936d3b8b4aec7 Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_termdebug.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index 6b6140c8cb..f87f96817b 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -1,5 +1,6 @@ " Test for the termdebug plugin +source shared.vim source check.vim CheckUnix @@ -50,7 +51,7 @@ func Test_termdebug_basic() edit XTD_basic.c Termdebug ./XTD_basic - call assert_equal(3, winnr('$')) + call WaitForAssert({-> assert_equal(3, winnr('$'))}) let gdb_buf = winbufnr(1) wincmd b Break 9 @@ -63,21 +64,22 @@ func Test_termdebug_basic() Run call Nterm_wait(gdb_buf, 400) redraw! - call assert_equal([ + call WaitForAssert({-> assert_equal([ \ {'lnum': 9, 'id': 12, 'name': 'debugPC', 'priority': 110, \ 'group': 'TermDebug'}, \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0', \ 'priority': 110, 'group': 'TermDebug'}], - \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) + "\ sign_getplaced('', #{group: 'TermDebug'})[0].signs)}) + \ sign_getplaced('', #{group: 'TermDebug'})[0].signs->reverse())}) Finish call Nterm_wait(gdb_buf) redraw! - call assert_equal([ + call WaitForAssert({-> assert_equal([ \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0', \ 'priority': 110, 'group': 'TermDebug'}, \ {'lnum': 20, 'id': 12, 'name': 'debugPC', \ 'priority': 110, 'group': 'TermDebug'}], - \ sign_getplaced('', #{group: 'TermDebug'})[0].signs) + \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)}) Continue wincmd t quit! -- cgit From 89d785e53015d7ba6a7f10e97a750b8d3431d3a9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 07:19:21 +0800 Subject: vim-patch:ca48202b6f46 runtime(termdebug): improve window handling, shorten var types closes vim/vim#13474 https://github.com/vim/vim/commit/ca48202b6f46cfb40a0d1d80033a2f3e8cb7b813 Co-authored-by: shane.xb.qian --- test/old/testdir/test_termdebug.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index f87f96817b..f3f4104dba 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -81,6 +81,34 @@ func Test_termdebug_basic() \ 'priority': 110, 'group': 'TermDebug'}], \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)}) Continue + + let cn = 0 + " 60 is approx spaceBuffer * 3 + if winwidth(0) <= 78 + 60 + Var + call assert_equal(winnr(), winnr('$')) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['leaf', 1000], ['leaf', 1003 + cn]]]) + let cn += 1 + bw! + Asm + call assert_equal(winnr(), winnr('$')) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['leaf', 1000], ['leaf', 1003 + cn]]]) + let cn += 1 + bw! + endif + set columns=160 + Var + call assert_equal(winnr(), winnr('$') - 1) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) + let cn += 1 + bw! + Asm + call assert_equal(winnr(), winnr('$') - 1) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) + let cn += 1 + bw! + set columns& + wincmd t quit! redraw! -- cgit From 77bb69d7b0d1ae8d9526b658eeea07b2d58ae78d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 08:38:25 +0800 Subject: vim-patch:7fbbd7fdc6df (#25944) runtime(termdebug): handle buffer-local mappings properly closes: vim/vim#13475 https://github.com/vim/vim/commit/7fbbd7fdc6df9dc198b3735cfbe8dbe8afd646f9 Co-authored-by: shane.xb.qian --- test/old/testdir/test_termdebug.vim | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index f3f4104dba..ab1a76000a 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -110,12 +110,88 @@ func Test_termdebug_basic() set columns& wincmd t + " Nvim: stop GDB process and process pending events + call chanclose(&channel) + call wait(0, '0') quit! redraw! + call WaitForAssert({-> assert_equal(1, winnr('$'))}) call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs) call delete('XTD_basic') %bw! endfunc +func Test_termdebug_mapping() + %bw! + call assert_equal(maparg('K', 'n', 0, 1)->empty(), 1) + call assert_equal(maparg('-', 'n', 0, 1)->empty(), 1) + call assert_equal(maparg('+', 'n', 0, 1)->empty(), 1) + Termdebug + call WaitForAssert({-> assert_equal(3, winnr('$'))}) + wincmd b + call assert_equal(maparg('K', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('-', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('+', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('K', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('-', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('+', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('K', 'n', 0, 1).rhs, ':Evaluate') + wincmd t + quit! + redraw! + call WaitForAssert({-> assert_equal(1, winnr('$'))}) + call assert_equal(maparg('K', 'n', 0, 1)->empty(), 1) + call assert_equal(maparg('-', 'n', 0, 1)->empty(), 1) + call assert_equal(maparg('+', 'n', 0, 1)->empty(), 1) + + %bw! + nnoremap K :echom "K" + nnoremap - :echom "-" + nnoremap + :echom "+" + Termdebug + call WaitForAssert({-> assert_equal(3, winnr('$'))}) + wincmd b + call assert_equal(maparg('K', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('-', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('+', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('K', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('-', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('+', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('K', 'n', 0, 1).rhs, ':Evaluate') + wincmd t + quit! + redraw! + call WaitForAssert({-> assert_equal(1, winnr('$'))}) + call assert_equal(maparg('K', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('-', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('+', 'n', 0, 1)->empty(), 0) + call assert_equal(maparg('K', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('-', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('+', 'n', 0, 1).buffer, 0) + call assert_equal(maparg('K', 'n', 0, 1).rhs, ':echom "K"') + + %bw! + nnoremap K :echom "bK" + nnoremap - :echom "b-" + nnoremap + :echom "b+" + Termdebug + call WaitForAssert({-> assert_equal(3, winnr('$'))}) + wincmd b + call assert_equal(maparg('K', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('-', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('+', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('K', 'n', 0, 1).rhs, ':echom "bK"') + wincmd t + quit! + redraw! + call WaitForAssert({-> assert_equal(1, winnr('$'))}) + call assert_equal(maparg('K', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('-', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('+', 'n', 0, 1).buffer, 1) + call assert_equal(maparg('K', 'n', 0, 1).rhs, ':echom "bK"') + + %bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 145d9ed0fcedd7bc61a2881a7c8f2d21ed52939f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Nov 2023 08:18:40 +0800 Subject: vim-patch:9.0.2100: CI: test_termdebug fails (#25997) Problem: CI: test_termdebug fails Solution: only test for a changed winlayout, if the window width actually changed Also, include an unrelated comment (which doesn't warrant its own patch number) https://github.com/vim/vim/commit/305127f9f2f6058b4ec071041a2c98f76114a9b0 Co-authored-by: Christian Brabandt --- test/old/testdir/test_termdebug.vim | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index ab1a76000a..f13850cb62 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -97,16 +97,22 @@ func Test_termdebug_basic() bw! endif set columns=160 + let winw = winwidth(0) Var - call assert_equal(winnr(), winnr('$') - 1) - call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) - let cn += 1 - bw! + if winwidth(0) < winw + call assert_equal(winnr(), winnr('$') - 1) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) + let cn += 1 + bw! + endif + let winw = winwidth(0) Asm - call assert_equal(winnr(), winnr('$') - 1) - call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) - let cn += 1 - bw! + if winwidth(0) < winw + call assert_equal(winnr(), winnr('$') - 1) + call assert_equal(winlayout(), ['col', [['leaf', 1002], ['leaf', 1001], ['row', [['leaf', 1003 + cn], ['leaf', 1000]]]]]) + let cn += 1 + bw! + endif set columns& wincmd t -- cgit From ad3568a70167ceb870931650afb7dcaed88640ec Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Nov 2023 18:18:28 +0800 Subject: vim-patch:9.0.2101: CI: test_termdebug may still fail (#26003) Problem: CI: test_termdebug may still fail Solution: use term_wait() to make it more robust closes: vim/vim#13529 https://github.com/vim/vim/commit/fdbadea4b60e5e1a0bf192dc5ee04d8ab06f4399 Co-authored-by: shane.xb.qian --- test/old/testdir/test_termdebug.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index f13850cb62..dca514db6e 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -97,6 +97,7 @@ func Test_termdebug_basic() bw! endif set columns=160 + call Nterm_wait(gdb_buf) let winw = winwidth(0) Var if winwidth(0) < winw @@ -114,11 +115,9 @@ func Test_termdebug_basic() bw! endif set columns& + call Nterm_wait(gdb_buf) wincmd t - " Nvim: stop GDB process and process pending events - call chanclose(&channel) - call wait(0, '0') quit! redraw! call WaitForAssert({-> assert_equal(1, winnr('$'))}) -- cgit From 74e23b3b2ad91d4308c409b4f7419a1d3955a5bb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 05:44:30 +0800 Subject: vim-patch:2dd613f57bf1 (#26009) runtime(termdebug): improve the breakpoint sign label (vim/vim#13525) // related vim/vim#12589 // that should be the last chat (I) with Bram, r.i.p https://github.com/vim/vim/commit/2dd613f57bf17eb8ff050bcb5510eb0279f5c9ab Co-authored-by: Shane-XB-Qian --- test/old/testdir/test_termdebug.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/old/testdir/test_termdebug.vim') diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim index dca514db6e..98a4bd3215 100644 --- a/test/old/testdir/test_termdebug.vim +++ b/test/old/testdir/test_termdebug.vim @@ -81,6 +81,32 @@ func Test_termdebug_basic() \ 'priority': 110, 'group': 'TermDebug'}], \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)}) Continue + call Nterm_wait(gdb_buf) + + let i = 2 + while i <= 258 + Break + call Nterm_wait(gdb_buf) + if i == 2 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint2.0')[0].text, '02')}) + endif + if i == 10 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint10.0')[0].text, '0A')}) + endif + if i == 168 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint168.0')[0].text, 'A8')}) + endif + if i == 255 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint255.0')[0].text, 'FF')}) + endif + if i == 256 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint256.0')[0].text, 'F+')}) + endif + if i == 258 + call WaitForAssert({-> assert_equal(sign_getdefined('debugBreakpoint258.0')[0].text, 'F+')}) + endif + let i += 1 + endwhile let cn = 0 " 60 is approx spaceBuffer * 3 -- cgit