]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-regexp-pdb.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / test / test-regexp-pdb.el
1 (require 'test-simple)
2 (load-file "../realgud/debugger/pdb/init.el")
3 (load-file "./regexp-helper.el")
4
5 (declare-function __FILE__ 'load-relative)
6 (declare-function prompt-match 'regexp-helper)
7
8 (test-simple-start)
9
10 (eval-when-compile
11 (defvar loc-pat) (defvar prompt-pat) (defvar realgud:pdb-pat-hash)
12 (defvar tb-pat) (defvar test-text) (defvar prompt-str)
13 (defvar bps-pat)
14 )
15
16 (set (make-local-variable 'bps-pat)
17 (gethash "brkpt-set" realgud:pdb-pat-hash))
18
19 (set (make-local-variable 'loc-pat)
20 (gethash "loc" realgud:pdb-pat-hash))
21
22 (set (make-local-variable 'prompt-pat)
23 (gethash "prompt" realgud:pdb-pat-hash))
24
25 (set (make-local-variable 'tb-pat)
26 (gethash "lang-backtrace" realgud:pdb-pat-hash))
27
28 ;; FIXME: we get a void variable somewhere in here when running
29 ;; even though we define it in lexical-let. Dunno why.
30 ;; setq however will workaround this.
31 (setq test-text
32 " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
33 (note "traceback location matching")
34
35 (assert-t (numberp (loc-match test-text tb-pat)) "basic traceback location")
36
37 (assert-equal "/usr/lib/python2.6/code.py"
38 (match-string (realgud-loc-pat-file-group tb-pat)
39 test-text))
40
41 (setq test-text
42 " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
43 (loc-match test-text tb-pat)
44 (assert-equal "281"
45 (match-string (realgud-loc-pat-line-group tb-pat)
46 test-text) "extract line number")
47
48 (note "breakpoint location matching")
49
50 (setq test-text "Breakpoint 1 at /src/git/code/gcd.py:13")
51 (assert-t (numberp (loc-match test-text bps-pat))
52 "basic breakpoint location")
53
54 (assert-equal "/src/git/code/gcd.py"
55 (match-string (realgud-loc-pat-file-group
56 bps-pat)
57 test-text)
58 "extract breakpoint file name")
59
60
61 (assert-equal "13"
62 (match-string (realgud-loc-pat-line-group
63 bps-pat)
64 test-text) "extract breakpoint line number")
65
66 ;; (set test-text "(c:\\working\\python\\helloworld.py:30): <module>")
67 ;;
68 ;; (assert-t (numberp (loc-match test-text loc-pat)) "MS DOS position location")
69 ;; ;;
70 ;; (assert-equal "c:\\working\\python\\helloworld.py"
71 ;; (match-string (realgud-loc-pat-file-group loc-pat)
72 ;; test-text)
73 ;; (format "Failing file group is %s"
74 ;; (realgud-loc-pat-file-group tb-pat))
75 ;; "extract file name")
76 ;; (assert-equal "30"
77 ;; (match-string (realgud-loc-pat-line-group loc-pat)
78 ;; test-text) "extract line number")
79
80 (setq test-text "> /usr/bin/ipython(24)<module>")
81 (assert-t (numberp (loc-match test-text loc-pat)) "position location")
82 (assert-equal "/usr/bin/ipython"
83 (match-string (realgud-loc-pat-file-group loc-pat)
84 test-text)
85 (format "Failing file group is %s"
86 (realgud-loc-pat-file-group tb-pat)))
87 (assert-equal "24"
88 (match-string (realgud-loc-pat-line-group
89 loc-pat)
90 test-text)
91 "extract line number")
92
93
94 (note "prompt matching")
95 (set (make-local-variable 'prompt-str) "(Pdb) ")
96 (prompt-match prompt-str nil "debugger prompt: %s")
97 (setq prompt-str "((Pdb)) ")
98 (prompt-match prompt-str nil "nested debugger prompt: %s")
99 (setq prompt-str "Pdb) ")
100 (assert-nil (numberp (loc-match prompt-str prompt-pat))
101 (format "%s %s" "invalid debugger prompt"
102 prompt-str))
103
104 (end-tests)