2 (require 'load-relative)
3 (load-file "./regexp-helper.el")
4 (load-file "../realgud/debugger/trepan2/init.el")
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-trepan2-init)
29 (defvar realgud-pat-bt)
31 (defvar realgud:trepan2-pat-hash)
35 (note "prompt matching")
37 (set (make-local-variable 'prompt-pat)
38 (gethash "prompt" realgud:trepan2-pat-hash))
40 (prompt-match "(trepan2) ")
42 (setup-regexp-vars realgud:trepan2-pat-hash)
44 (note "debugger-backtrace")
45 (setq realgud-pat-bt (gethash "debugger-backtrace"
46 realgud:trepan2-pat-hash))
48 "##0 gcd(a=3, b=5) called from file '/tmp/test/gcd.py' at line 31
50 '/tmp/test/gcd2.py' at line 41
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"
62 (match-beginning file-group)
63 (match-end file-group)))
66 (match-beginning line-group)
67 (match-end line-group)))
68 (setq test-pos (match-end 0))
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"
76 (match-beginning file-group)
77 (match-end file-group)))
80 (match-beginning line-group)
81 (match-end line-group)))
82 (setq test-pos (match-end 0))
83 (assert-equal 120 test-pos)
85 (setq helper-tb (gethash "lang-backtrace" realgud:trepan2-pat-hash))
87 (note "traceback location matching")
89 " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
91 (assert-t (numberp (loc-match test-s1 helper-tb))
92 "basic traceback location")
94 (assert-equal "/usr/lib/python2.6/code.py"
95 (match-string (realgud-loc-pat-file-group helper-tb)
97 (format "extract file - failing file group is %s"
98 (realgud-loc-pat-file-group helper-tb)))
100 (match-string (realgud-loc-pat-line-group helper-tb)
101 test-s1) "extract line number")
103 (note "breakpoint location matching")
106 "Breakpoint 1 set at line 13 of file /src/git/code/gcd.py")
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")
114 (match-string (realgud-loc-pat-line-group helper-bps)
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)
123 (format "extract file - Failing file group is %s"
124 (realgud-loc-pat-file-group helper-tb)))
126 (match-string (realgud-loc-pat-line-group helper-loc)
127 test-s1) "extract line number")
129 (setq test-s1 "(/usr/bin/ipython:24): <module>")
130 (assert-t (numberp (loc-match test-s1 helper-loc))
132 (assert-equal "/usr/bin/ipython"
133 (match-string (realgud-loc-pat-file-group helper-loc)
135 (format "extract-file - failing file group is %s"
136 (realgud-loc-pat-file-group helper-tb)))
138 (match-string (realgud-loc-pat-line-group helper-loc)
140 "extract line number")
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)
148 (format "extract-file name - failing file group is %s"
149 (realgud-loc-pat-file-group helper-tb)))
151 (match-string (realgud-loc-pat-line-group helper-loc)
152 test-s1) "extract line number")
157 "(/usr/local/bin/trepan2:4): <module>\n-- 4
\e[34mimport
\e[39;49;00m
\e[39;49;00m
\e[04m
\e[36msys
\e[39;49;00m\n(trepan2) ")
158 (assert-t (numberp (loc-match test-s1 helper-loc)) "source location")
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")