comparison src/testdir/test_termdebug.vim @ 32998:d55bf5bbcb6f v9.0.1791

patch 9.0.1791: No tests for the termdebug plugin Commit: https://github.com/vim/vim/commit/58f39d89a8adff51ab04893d1fd28e3767979f9f Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Aug 27 11:14:44 2023 +0200 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: #12927 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 27 Aug 2023 11:30:06 +0200
parents
children 50fe2cd56d3a
comparison
equal deleted inserted replaced
32997:3ee505e381ec 32998:d55bf5bbcb6f
1 " Test for the termdebug plugin
2
3 source check.vim
4
5 CheckUnix
6 CheckFeature terminal
7 CheckExecutable gdb
8 CheckExecutable gcc
9
10 let g:GDB = exepath('gdb')
11 if g:GDB->empty()
12 throw 'Skpped: gdb is not found in $PATH'
13 endif
14
15 let g:GCC = exepath('gcc')
16 if g:GCC->empty()
17 throw 'Skpped: gcc is not found in $PATH'
18 endif
19
20 packadd termdebug
21
22 func Test_termdebug_basic()
23 let lines =<< trim END
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 int isprime(int n)
28 {
29 if (n <= 1)
30 return 0;
31
32 for (int i = 2; i <= n / 2; i++)
33 if (n % i == 0)
34 return 0;
35
36 return 1;
37 }
38
39 int main(int argc, char *argv[])
40 {
41 int n = 7;
42
43 printf("%d is %s prime\n", n, isprime(n) ? "a" : "not a");
44
45 return 0;
46 }
47 END
48 call writefile(lines, 'XTD_basic.c', 'D')
49 call system($'{g:GCC} -g -o XTD_basic XTD_basic.c')
50
51 edit XTD_basic.c
52 Termdebug ./XTD_basic
53 call assert_equal(3, winnr('$'))
54 let gdb_buf = winbufnr(1)
55 wincmd b
56 Break 9
57 call term_wait(gdb_buf)
58 redraw!
59 call assert_equal([
60 \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0',
61 \ 'priority': 110, 'group': 'TermDebug'}],
62 \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)
63 Run
64 call term_wait(gdb_buf, 200)
65 redraw!
66 call assert_equal([
67 \ {'lnum': 9, 'id': 12, 'name': 'debugPC', 'priority': 110,
68 \ 'group': 'TermDebug'},
69 \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0',
70 \ 'priority': 110, 'group': 'TermDebug'}],
71 \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)
72 Finish
73 call term_wait(gdb_buf)
74 redraw!
75 call assert_equal([
76 \ {'lnum': 9, 'id': 1014, 'name': 'debugBreakpoint1.0',
77 \ 'priority': 110, 'group': 'TermDebug'},
78 \ {'lnum': 20, 'id': 12, 'name': 'debugPC',
79 \ 'priority': 110, 'group': 'TermDebug'}],
80 \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)
81 Continue
82 wincmd t
83 quit!
84 redraw!
85 call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs)
86
87 call delete('XTD_basic')
88 %bw!
89 endfunc
90
91 " vim: shiftwidth=2 sts=2 expandtab