]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-regexp-trepan3k.el
aedda29f85b1346803db7feceba64603fdb19094
[gnu-emacs-elpa] / packages / realgud / test / test-regexp-trepan3k.el
1 (require 'test-simple)
2 (require 'load-relative)
3 (load-file "./regexp-helper.el")
4 (load-file "../realgud/debugger/trepan3k/init.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 (declare-function setup-regexp-vars 'regexp-helper)
14 (declare-function realgud-loc-pat-text-group 'realgud-trepan3k-init)
15
16
17 (test-simple-start)
18
19 (eval-when-compile
20 (defvar file-group)
21 (defvar frame-re)
22 (defvar line-group)
23 (defvar num-group)
24 (defvar test-pos)
25 (defvar test-s1)
26 (defvar helper-tb)
27 (defvar helper-bps)
28 (defvar prompt-pat)
29 (defvar realgud-pat-bt)
30 (defvar helper-loc)
31 (defvar realgud:trepan3k-pat-hash)
32 (defvar trepan3k-text)
33 )
34
35 (note "prompt matching")
36
37 (set (make-local-variable 'prompt-pat)
38 (gethash "prompt" realgud:trepan3k-pat-hash))
39
40 (prompt-match "(trepan3k) ")
41
42 (setup-regexp-vars realgud:trepan3k-pat-hash)
43
44 (note "debugger-backtrace")
45 (setq realgud-pat-bt (gethash "debugger-backtrace"
46 realgud:trepan3k-pat-hash))
47 (setq test-s1
48 "##0 gcd(a=3, b=5) called from file '/tmp/test/gcd.py' at line 31
49 ->1 <module> exec()
50 '/tmp/test/gcd2.py' at line 41
51 ")
52 (setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
53 (setq num-group (realgud-loc-pat-num realgud-pat-bt))
54 (setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
55 (setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
56 (assert-equal 0 (string-match frame-re test-s1))
57 (assert-equal "0" (substring test-s1
58 (match-beginning num-group)
59 (match-end num-group)))
60 (assert-equal "/tmp/test/gcd.py"
61 (substring test-s1
62 (match-beginning file-group)
63 (match-end file-group)))
64 (assert-equal "31"
65 (substring test-s1
66 (match-beginning line-group)
67 (match-end line-group)))
68 (setq test-pos (match-end 0))
69
70 (assert-equal 64 (string-match frame-re test-s1 test-pos))
71 (assert-equal "1" (substring test-s1
72 (match-beginning num-group)
73 (match-end num-group)))
74 (assert-equal "/tmp/test/gcd2.py"
75 (substring test-s1
76 (match-beginning file-group)
77 (match-end file-group)))
78 (assert-equal "41"
79 (substring test-s1
80 (match-beginning line-group)
81 (match-end line-group)))
82 (setq test-pos (match-end 0))
83 (assert-equal 120 test-pos)
84
85 (setq helper-tb (gethash "lang-backtrace" realgud:trepan3k-pat-hash))
86
87 (note "traceback location matching")
88 (setq test-s1
89 " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
90
91 (assert-t (numberp (loc-match test-s1 helper-tb))
92 "basic traceback location")
93
94 (assert-equal "/usr/lib/python2.6/code.py"
95 (match-string (realgud-loc-pat-file-group helper-tb)
96 test-s1)
97 (format "extract file - failing file group is %s"
98 (realgud-loc-pat-file-group helper-tb)))
99 (assert-equal "281"
100 (match-string (realgud-loc-pat-line-group helper-tb)
101 test-s1) "extract line number")
102
103 (note "breakpoint location matching")
104
105 (setq test-s1
106 "Breakpoint 1 set at line 13 of file /src/git/code/gcd.py")
107
108 (assert-t (numberp (loc-match test-s1 helper-bps))
109 "basic breakpoint location")
110 (assert-equal "/src/git/code/gcd.py"
111 (match-string (realgud-loc-pat-file-group helper-bps)
112 test-s1) "extract breakpoint file name")
113 (assert-equal "13"
114 (match-string (realgud-loc-pat-line-group helper-bps)
115 test-s1)
116 "extract breakpoint line number")
117 (setq test-s1 "(c:\\working\\python\\helloworld.py:30): <module>")
118 (assert-t (numberp (loc-match test-s1 helper-loc))
119 "MS DOS position location")
120 (assert-equal "c:\\working\\python\\helloworld.py"
121 (match-string (realgud-loc-pat-file-group helper-loc)
122 test-s1)
123 (format "extract file - Failing file group is %s"
124 (realgud-loc-pat-file-group helper-tb)))
125 (assert-equal "30"
126 (match-string (realgud-loc-pat-line-group helper-loc)
127 test-s1) "extract line number")
128
129 (setq test-s1 "(/usr/bin/ipython:24): <module>")
130 (assert-t (numberp (loc-match test-s1 helper-loc))
131 "position location")
132 (assert-equal "/usr/bin/ipython"
133 (match-string (realgud-loc-pat-file-group helper-loc)
134 test-s1)
135 (format "extract-file - failing file group is %s"
136 (realgud-loc-pat-file-group helper-tb)))
137 (assert-equal "24"
138 (match-string (realgud-loc-pat-line-group helper-loc)
139 test-s1)
140 "extract line number")
141
142 (setq test-s1
143 "(/tmp/eval_stringzDKTfr.py:1 remapped <string>): <module>")
144 (assert-t (numberp (loc-match test-s1 helper-loc)) "position location")
145 (assert-equal "/tmp/eval_stringzDKTfr.py"
146 (match-string (realgud-loc-pat-file-group helper-loc)
147 test-s1)
148 (format "extract-file name - failing file group is %s"
149 (realgud-loc-pat-file-group helper-tb)))
150 (assert-equal "1"
151 (match-string (realgud-loc-pat-line-group helper-loc)
152 test-s1) "extract line number")
153
154 (note "source text")
155
156 (setq test-s1
157 "(/usr/local/bin/trepan3k:4): <module>\n-- 4 \e[34mimport\e[39;49;00m \e[39;49;00m\e[04m\e[36msys\e[39;49;00m\n(trepan3k) ")
158 (assert-t (numberp (loc-match test-s1 helper-loc)) "source location")
159 (assert-equal
160 "\e[34mimport\e[39;49;00m \e[39;49;00m\e[04m\e[36msys\e[39;49;00m"
161 (match-string (realgud-loc-pat-text-group helper-loc)
162 test-s1) "extract source text")
163
164 (end-tests)