]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-regexp-bashdb.el
0e7da4c4916515518710f35486fa7e186fc9fbde
[gnu-emacs-elpa] / packages / realgud / test / test-regexp-bashdb.el
1 (require 'test-simple)
2 (require 'load-relative)
3 (load-file "../realgud/debugger/bashdb/init.el")
4 (load-file "./regexp-helper.el")
5
6 (declare-function loc-match 'realgud-helper)
7 (declare-function prompt-match 'regexp-helper)
8 (declare-function realgud-loc-pat-num 'realgud-regexp)
9 (declare-function realgud-loc-pat-regexp 'realgud-regexp)
10 (declare-function realgud-loc-pat-file-group 'realgud-regexp)
11 (declare-function realgud-loc-pat-line-group 'realgud-regexp)
12 (declare-function __FILE__ 'load-relative)
13
14 (test-simple-start)
15
16 (eval-when-compile
17 (defvar file-group)
18 (defvar frame-re)
19 (defvar line-group)
20 (defvar num-group)
21 (defvar test-pos)
22 (defvar prompt-pat)
23 (defvar realgud:bashdb-pat-hash)
24 (defvar realgud-pat-bt)
25 (defvar test-s1)
26 (defvar test-text)
27 (defvar brkpt-del)
28 (defvar bp-del-pat)
29 )
30
31 (set (make-local-variable 'bp-del-pat)
32 (gethash "brkpt-del" realgud:bashdb-pat-hash))
33
34 (note "bashdb prompt matching")
35 (set (make-local-variable 'prompt-pat)
36 (gethash "prompt" realgud:bashdb-pat-hash))
37 (prompt-match "bashdb<10> " "10")
38 (prompt-match "bashdb<(5)> " "5" "subshell prompt %s")
39 (prompt-match "bashdb<<1>> " "1" "nested debug prompt %s")
40
41 (note "debugger-backtrace")
42 (setq realgud-pat-bt (gethash "debugger-backtrace"
43 realgud:bashdb-pat-hash))
44 (setq test-s1
45 "->0 in file `/etc/apparmor/functions' at line 24
46 ##1 source(\"/etc/apparmor/functions\") called from file `/etc/init.d/apparmor' at line 35
47 ##2 source(\"/etc/init.d/apparmor\") called from file `/usr/local/bin/bashdb' at line 140
48 ##3 main() called from file `/bin/bashdb' at line 0
49 ")
50 (setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
51 (setq num-group (realgud-loc-pat-num realgud-pat-bt))
52 (setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
53 (setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
54 (assert-equal 0 (string-match frame-re test-s1))
55 (assert-equal "0" (substring test-s1
56 (match-beginning num-group)
57 (match-end num-group)))
58 (assert-equal "/etc/apparmor/functions"
59 (substring test-s1
60 (match-beginning file-group)
61 (match-end file-group)))
62 (assert-equal "24"
63 (substring test-s1
64 (match-beginning line-group)
65 (match-end line-group)))
66 (setq test-pos (match-end 0))
67
68 (assert-equal 49 (string-match frame-re test-s1 test-pos))
69 (assert-equal "1" (substring test-s1
70 (match-beginning num-group)
71 (match-end num-group)))
72 (assert-equal "/etc/init.d/apparmor"
73 (substring test-s1
74 (match-beginning file-group)
75 (match-end file-group)))
76 (assert-equal "35"
77 (substring test-s1
78 (match-beginning line-group)
79 (match-end line-group)))
80 (setq test-pos (match-end 0))
81 (assert-equal 138 (string-match frame-re test-s1 test-pos))
82 (assert-equal "2" (substring test-s1
83 (match-beginning num-group)
84 (match-end num-group)))
85 (assert-equal "/usr/local/bin/bashdb"
86 (substring test-s1
87 (match-beginning file-group)
88 (match-end file-group)))
89 (assert-equal "140"
90 (substring test-s1
91 (match-beginning line-group)
92 (match-end line-group)))
93 (setq test-pos (match-end 0))
94 (assert-equal 226 (string-match frame-re test-s1 test-pos))
95 (assert-equal "3" (substring test-s1
96 (match-beginning num-group)
97 (match-end num-group)))
98 (assert-equal "/bin/bashdb"
99 (substring test-s1
100 (match-beginning file-group)
101 (match-end file-group)))
102
103 (note "breakpoint delete matching")
104 (setq test-text "Removed 1 breakpoint(s).\n")
105 (assert-t (numberp (loc-match test-text bp-del-pat)) "breakpoint delete matching")
106
107
108 (end-tests)