debugger 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +10 -0
- data/CHANGES +334 -0
- data/ChangeLog +5655 -0
- data/INSTALL.SVN +154 -0
- data/LICENSE +23 -0
- data/Makefile.am +14 -0
- data/OLD_README +122 -0
- data/README.md +10 -0
- data/Rakefile +266 -0
- data/autogen.sh +4 -0
- data/bin/rdebug +398 -0
- data/cli/ruby-debug.rb +173 -0
- data/cli/ruby-debug/command.rb +228 -0
- data/cli/ruby-debug/commands/breakpoints.rb +153 -0
- data/cli/ruby-debug/commands/catchpoint.rb +55 -0
- data/cli/ruby-debug/commands/condition.rb +49 -0
- data/cli/ruby-debug/commands/continue.rb +38 -0
- data/cli/ruby-debug/commands/control.rb +107 -0
- data/cli/ruby-debug/commands/display.rb +120 -0
- data/cli/ruby-debug/commands/edit.rb +48 -0
- data/cli/ruby-debug/commands/enable.rb +202 -0
- data/cli/ruby-debug/commands/eval.rb +176 -0
- data/cli/ruby-debug/commands/finish.rb +42 -0
- data/cli/ruby-debug/commands/frame.rb +301 -0
- data/cli/ruby-debug/commands/help.rb +56 -0
- data/cli/ruby-debug/commands/info.rb +467 -0
- data/cli/ruby-debug/commands/irb.rb +123 -0
- data/cli/ruby-debug/commands/jump.rb +66 -0
- data/cli/ruby-debug/commands/kill.rb +51 -0
- data/cli/ruby-debug/commands/list.rb +94 -0
- data/cli/ruby-debug/commands/method.rb +84 -0
- data/cli/ruby-debug/commands/quit.rb +39 -0
- data/cli/ruby-debug/commands/reload.rb +40 -0
- data/cli/ruby-debug/commands/save.rb +90 -0
- data/cli/ruby-debug/commands/set.rb +221 -0
- data/cli/ruby-debug/commands/show.rb +247 -0
- data/cli/ruby-debug/commands/skip.rb +35 -0
- data/cli/ruby-debug/commands/source.rb +36 -0
- data/cli/ruby-debug/commands/stepping.rb +81 -0
- data/cli/ruby-debug/commands/threads.rb +189 -0
- data/cli/ruby-debug/commands/tmate.rb +36 -0
- data/cli/ruby-debug/commands/trace.rb +57 -0
- data/cli/ruby-debug/commands/variables.rb +199 -0
- data/cli/ruby-debug/debugger.rb +5 -0
- data/cli/ruby-debug/helper.rb +69 -0
- data/cli/ruby-debug/interface.rb +232 -0
- data/cli/ruby-debug/processor.rb +474 -0
- data/configure.ac +12 -0
- data/debugger.gemspec +24 -0
- data/doc/.cvsignore +42 -0
- data/doc/Makefile.am +63 -0
- data/doc/emacs-notes.txt +38 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/rdebug.1 +241 -0
- data/doc/ruby-debug.texi +3791 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/emacs/Makefile.am +130 -0
- data/emacs/rdebug-annotate.el +385 -0
- data/emacs/rdebug-breaks.el +407 -0
- data/emacs/rdebug-cmd.el +92 -0
- data/emacs/rdebug-core.el +502 -0
- data/emacs/rdebug-dbg.el +62 -0
- data/emacs/rdebug-error.el +79 -0
- data/emacs/rdebug-fns.el +111 -0
- data/emacs/rdebug-frames.el +230 -0
- data/emacs/rdebug-gud.el +242 -0
- data/emacs/rdebug-help.el +104 -0
- data/emacs/rdebug-info.el +83 -0
- data/emacs/rdebug-layouts.el +180 -0
- data/emacs/rdebug-locring.el +118 -0
- data/emacs/rdebug-output.el +106 -0
- data/emacs/rdebug-regexp.el +118 -0
- data/emacs/rdebug-secondary.el +260 -0
- data/emacs/rdebug-shortkey.el +175 -0
- data/emacs/rdebug-source.el +568 -0
- data/emacs/rdebug-track.el +392 -0
- data/emacs/rdebug-varbuf.el +150 -0
- data/emacs/rdebug-vars.el +125 -0
- data/emacs/rdebug-watch.el +132 -0
- data/emacs/rdebug.el +326 -0
- data/emacs/test/elk-test.el +242 -0
- data/emacs/test/test-annotate.el +103 -0
- data/emacs/test/test-cmd.el +116 -0
- data/emacs/test/test-core.el +104 -0
- data/emacs/test/test-fns.el +65 -0
- data/emacs/test/test-frames.el +62 -0
- data/emacs/test/test-gud.el +35 -0
- data/emacs/test/test-indent.el +58 -0
- data/emacs/test/test-regexp.el +144 -0
- data/emacs/test/test-shortkey.el +61 -0
- data/ext/ruby_debug/breakpoint.c +586 -0
- data/ext/ruby_debug/extconf.rb +49 -0
- data/ext/ruby_debug/ruby_debug.c +2624 -0
- data/ext/ruby_debug/ruby_debug.h +148 -0
- data/lib/ChangeLog +1065 -0
- data/lib/debugger.rb +7 -0
- data/lib/debugger/version.rb +3 -0
- data/lib/ruby-debug-base.rb +304 -0
- data/rdbg.rb +33 -0
- data/runner.sh +7 -0
- data/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/base/base.rb +74 -0
- data/test/base/binding.rb +31 -0
- data/test/base/catchpoint.rb +26 -0
- data/test/base/load.rb +40 -0
- data/test/bp_loop_issue.rb +3 -0
- data/test/classes.rb +11 -0
- data/test/cli/commands/catchpoint_test.rb +36 -0
- data/test/cli/commands/unit/regexp.rb +42 -0
- data/test/config.yaml +8 -0
- data/test/data/annotate.cmd +29 -0
- data/test/data/annotate.right +139 -0
- data/test/data/break_bad.cmd +18 -0
- data/test/data/break_bad.right +28 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/breakpoints.cmd +38 -0
- data/test/data/breakpoints.right +98 -0
- data/test/data/catch.cmd +20 -0
- data/test/data/catch.right +49 -0
- data/test/data/catch2.cmd +19 -0
- data/test/data/catch2.right +65 -0
- data/test/data/catch3.cmd +11 -0
- data/test/data/catch3.right +37 -0
- data/test/data/condition.cmd +28 -0
- data/test/data/condition.right +65 -0
- data/test/data/ctrl.cmd +23 -0
- data/test/data/ctrl.right +70 -0
- data/test/data/display.cmd +24 -0
- data/test/data/display.right +44 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +12 -0
- data/test/data/edit.right +19 -0
- data/test/data/emacs_basic.cmd +43 -0
- data/test/data/emacs_basic.right +106 -0
- data/test/data/enable.cmd +20 -0
- data/test/data/enable.right +36 -0
- data/test/data/finish.cmd +16 -0
- data/test/data/finish.right +31 -0
- data/test/data/frame.cmd +26 -0
- data/test/data/frame.right +55 -0
- data/test/data/help.cmd +20 -0
- data/test/data/help.right +21 -0
- data/test/data/history.right +7 -0
- data/test/data/info-thread.cmd +13 -0
- data/test/data/info-thread.right +37 -0
- data/test/data/info-var-bug2.cmd +5 -0
- data/test/data/info-var-bug2.right +10 -0
- data/test/data/info-var.cmd +23 -0
- data/test/data/info-var.right +52 -0
- data/test/data/info.cmd +21 -0
- data/test/data/info.right +65 -0
- data/test/data/jump.cmd +16 -0
- data/test/data/jump.right +56 -0
- data/test/data/jump2.cmd +16 -0
- data/test/data/jump2.right +44 -0
- data/test/data/linetrace.cmd +6 -0
- data/test/data/linetrace.right +23 -0
- data/test/data/list.cmd +19 -0
- data/test/data/list.right +127 -0
- data/test/data/method.cmd +10 -0
- data/test/data/method.right +21 -0
- data/test/data/methodsig.cmd +10 -0
- data/test/data/methodsig.right +20 -0
- data/test/data/next.cmd +22 -0
- data/test/data/next.right +61 -0
- data/test/data/noquit.right +1 -0
- data/test/data/output.cmd +6 -0
- data/test/data/output.right +31 -0
- data/test/data/pm-bug.cmd +7 -0
- data/test/data/pm-bug.right +12 -0
- data/test/data/post-mortem-next.cmd +8 -0
- data/test/data/post-mortem-next.right +14 -0
- data/test/data/post-mortem-osx.right +31 -0
- data/test/data/post-mortem.cmd +13 -0
- data/test/data/post-mortem.right +32 -0
- data/test/data/quit.cmd +6 -0
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +23 -0
- data/test/data/save.cmd +34 -0
- data/test/data/save.right +59 -0
- data/test/data/scope-var.cmd +42 -0
- data/test/data/scope-var.right +587 -0
- data/test/data/setshow.cmd +56 -0
- data/test/data/setshow.right +98 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +15 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +50 -0
- data/test/data/test-init-cygwin.right +7 -0
- data/test/data/test-init-osx.right +4 -0
- data/test/data/test-init.right +5 -0
- data/test/data/trace.right +14 -0
- data/test/dollar-0.rb +5 -0
- data/test/gcd-dbg-nox.rb +31 -0
- data/test/gcd-dbg.rb +30 -0
- data/test/gcd.rb +18 -0
- data/test/helper.rb +144 -0
- data/test/info-var-bug.rb +47 -0
- data/test/info-var-bug2.rb +2 -0
- data/test/jump.rb +14 -0
- data/test/jump2.rb +27 -0
- data/test/next.rb +18 -0
- data/test/null.rb +1 -0
- data/test/output.rb +2 -0
- data/test/pm-base.rb +22 -0
- data/test/pm-bug.rb +3 -0
- data/test/pm-catch.rb +12 -0
- data/test/pm-catch2.rb +27 -0
- data/test/pm-catch3.rb +47 -0
- data/test/pm.rb +11 -0
- data/test/raise.rb +3 -0
- data/test/rdebug-save.1 +7 -0
- data/test/runall +12 -0
- data/test/scope-var.rb +29 -0
- data/test/tdebug.rb +248 -0
- data/test/test-annotate.rb +25 -0
- data/test/test-break-bad.rb +37 -0
- data/test/test-breakpoints.rb +25 -0
- data/test/test-catch.rb +25 -0
- data/test/test-catch2.rb +25 -0
- data/test/test-catch3.rb +25 -0
- data/test/test-condition.rb +25 -0
- data/test/test-ctrl.rb +55 -0
- data/test/test-display.rb +26 -0
- data/test/test-dollar-0.rb +40 -0
- data/test/test-edit.rb +26 -0
- data/test/test-emacs-basic.rb +26 -0
- data/test/test-enable.rb +25 -0
- data/test/test-finish.rb +34 -0
- data/test/test-frame.rb +34 -0
- data/test/test-help.rb +60 -0
- data/test/test-hist.rb +68 -0
- data/test/test-info-thread.rb +32 -0
- data/test/test-info-var.rb +47 -0
- data/test/test-info.rb +26 -0
- data/test/test-init.rb +44 -0
- data/test/test-jump.rb +35 -0
- data/test/test-list.rb +25 -0
- data/test/test-method.rb +34 -0
- data/test/test-next.rb +25 -0
- data/test/test-output.rb +26 -0
- data/test/test-quit.rb +30 -0
- data/test/test-raise.rb +25 -0
- data/test/test-save.rb +31 -0
- data/test/test-scope-var.rb +25 -0
- data/test/test-setshow.rb +25 -0
- data/test/test-source.rb +25 -0
- data/test/test-stepping.rb +26 -0
- data/test/test-trace.rb +47 -0
- data/test/thread1.rb +26 -0
- data/test/trunc-call.rb +31 -0
- metadata +364 -0
@@ -0,0 +1,242 @@
|
|
1
|
+
;;; elk-test.el --- Emacs Lisp testing suite
|
2
|
+
|
3
|
+
;; Copyright (C) 2006 Nikolaj Schumacher <bugs * nschum , de>
|
4
|
+
|
5
|
+
;;; License
|
6
|
+
|
7
|
+
;; This program is free software; you can redistribute it and/or
|
8
|
+
;; modify it under the terms of the GNU General Public License
|
9
|
+
;; as published by the Free Software Foundation; either version 2
|
10
|
+
;; of the License, or (at your option) any later version.
|
11
|
+
|
12
|
+
;; This program is distributed in the hope that it will be useful,
|
13
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
;; GNU General Public License for more details.
|
16
|
+
|
17
|
+
;; You should have received a copy of the GNU General Public License
|
18
|
+
;; along with this program; if not, write to the Free Software
|
19
|
+
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
20
|
+
|
21
|
+
;;; Usage
|
22
|
+
|
23
|
+
;; Use `deftest' to define a test and `run-elk-test' to run it.
|
24
|
+
;; Create test bundles with `defsuite' or `build-suite'.
|
25
|
+
;; Verify your code with `assert-equal', `assert-eq', `assert-eql',
|
26
|
+
;; `assert-nonnil', `assert-t', `assert-nil' and `assert-error'
|
27
|
+
;; to verify your code.
|
28
|
+
|
29
|
+
;;; Examples
|
30
|
+
|
31
|
+
;; (deftest "test1"
|
32
|
+
;; (assert-equal t t)
|
33
|
+
;; (assert-eq t 'foo))
|
34
|
+
|
35
|
+
;; (defsuite "suite1"
|
36
|
+
;; (deftest "test1" (assert-equal t t)))
|
37
|
+
|
38
|
+
;; (deftest "test2"
|
39
|
+
;; (assert-equal t t))
|
40
|
+
;; (build-suite "combined-suite" "test1" "test2")
|
41
|
+
|
42
|
+
;; (run-elk-test "combined-suite")
|
43
|
+
;; (run-elk-test)
|
44
|
+
|
45
|
+
(require 'cl)
|
46
|
+
|
47
|
+
(defvar elk-test-run-on-define nil
|
48
|
+
"If non-nil, run elk-test tests/suites immediately when defining them.")
|
49
|
+
|
50
|
+
(defvar elk-test-map (make-hash-table :test 'equal)
|
51
|
+
"A map of elk-test test/suite names to their implementation.")
|
52
|
+
|
53
|
+
(defvar elk-test-list nil
|
54
|
+
"A list of all defined elk-test tests/suites.")
|
55
|
+
|
56
|
+
(defun elk-test-clear ()
|
57
|
+
"Remove all tests from memory."
|
58
|
+
(setq elk-test-map (make-hash-table :test 'equal)
|
59
|
+
elk-test-list nil))
|
60
|
+
|
61
|
+
(defun run-elk-test (name &optional string-result)
|
62
|
+
"Run the test case defined as NAME.
|
63
|
+
The result is a list of errors strings, unless STRING-RESULT is set, in which
|
64
|
+
case a message describing the errors or success is displayed and returned."
|
65
|
+
(interactive
|
66
|
+
(list (completing-read "Test name: " elk-test-list nil t)))
|
67
|
+
(let ((name name))
|
68
|
+
(let ((elk-test-errors nil)
|
69
|
+
(test-or-suite (gethash name elk-test-map)))
|
70
|
+
(if (not test-or-suite)
|
71
|
+
(error "Undefined test <%s>" name)
|
72
|
+
(if (equal (car test-or-suite) 'suite)
|
73
|
+
;; is test suite
|
74
|
+
(let ((map (cadr test-or-suite)))
|
75
|
+
(dolist (test (caddr test-or-suite))
|
76
|
+
(setq elk-test-errors
|
77
|
+
(append elk-test-errors
|
78
|
+
(run-elk-test-internal (gethash test map))))))
|
79
|
+
;; is simple test
|
80
|
+
(setq elk-test-errors (run-elk-test-internal test-or-suite)))
|
81
|
+
(if (or string-result (interactive-p))
|
82
|
+
(message (if elk-test-errors
|
83
|
+
(mapconcat 'identity elk-test-errors "\n")
|
84
|
+
"Test run was successful."))
|
85
|
+
elk-test-errors)))))
|
86
|
+
|
87
|
+
(defun run-elk-tests-buffer (&optional buffer)
|
88
|
+
"Execute BUFFER as lisp code and run all tests therein."
|
89
|
+
(interactive)
|
90
|
+
(let* ((elk-test-list)
|
91
|
+
(elk-test-map (make-hash-table :test 'equal))
|
92
|
+
(elk-test-run-on-define nil)
|
93
|
+
(inhibit-read-only t)
|
94
|
+
(buffer-name (buffer-name buffer))
|
95
|
+
(success t)
|
96
|
+
(parse-res (condition-case err (eval-buffer buffer) (error err))))
|
97
|
+
(if parse-res
|
98
|
+
(message "Parsing buffer <%s> failed:\n%s"
|
99
|
+
buffer-name parse-res)
|
100
|
+
(let ((out-buffer (get-buffer-create
|
101
|
+
(concat "*elk-test run " buffer-name "*")))
|
102
|
+
failure)
|
103
|
+
(with-current-buffer out-buffer
|
104
|
+
(erase-buffer)
|
105
|
+
(dolist (test elk-test-list)
|
106
|
+
(message "running <%s>" test)
|
107
|
+
(let ((results (run-elk-test test)))
|
108
|
+
(when results
|
109
|
+
(setq failure t)
|
110
|
+
(insert "test <" test "> failed:\n")
|
111
|
+
(dolist (result results)
|
112
|
+
(insert "* " result "\n"))))))
|
113
|
+
(if failure
|
114
|
+
(display-buffer out-buffer)
|
115
|
+
(kill-buffer out-buffer)
|
116
|
+
(message "Test run was successful."))))))
|
117
|
+
|
118
|
+
(defun run-elk-test-internal (test)
|
119
|
+
(let ((elk-test-errors nil))
|
120
|
+
(dolist (sexpr test)
|
121
|
+
(let ((problem (condition-case err (progn (eval sexpr) nil) (error err))))
|
122
|
+
(when problem
|
123
|
+
(push (message "%s" problem) elk-test-errors))))
|
124
|
+
elk-test-errors))
|
125
|
+
|
126
|
+
(defmacro elk-test-error (format-string &rest args)
|
127
|
+
"Create an error string as the result of a failed elk-test assertion.
|
128
|
+
The first argument is a format control string, and the rest are data to be
|
129
|
+
formatted under control of the string. See `format' for details.
|
130
|
+
|
131
|
+
The result will be displayed, returned and if called inside of `run-elk-test'
|
132
|
+
added to the internal error list."
|
133
|
+
`(let ((string (message ,format-string ,@args)))
|
134
|
+
(when (boundp 'elk-test-errors)
|
135
|
+
(push string elk-test-errors))
|
136
|
+
string))
|
137
|
+
|
138
|
+
(defmacro assert-equal (expected actual)
|
139
|
+
"Assert that ACTUAL equals EXPECTED, or signal a warning."
|
140
|
+
`(unless (equal ,expected ,actual)
|
141
|
+
(elk-test-error "assert-equal for <%s> failed: expected <%s>, was <%s>"
|
142
|
+
',actual ,expected ,actual)))
|
143
|
+
|
144
|
+
(defmacro assert-eq (expected actual)
|
145
|
+
"Assert that ACTUAL equals EXPECTED, or signal a warning."
|
146
|
+
`(unless (eq ,expected ,actual)
|
147
|
+
(elk-test-error "assert-eq for <%s> failed: expected <%s>, was <%s>"
|
148
|
+
',actual ,expected ,actual)))
|
149
|
+
|
150
|
+
(defmacro assert-eql (expected actual)
|
151
|
+
"Assert that ACTUAL equals EXPECTED, or signal a warning."
|
152
|
+
`(unless (eql ,expected ,actual)
|
153
|
+
(elk-test-error "assert-eql for <%s> failed: expected <%s>, was <%s>"
|
154
|
+
',actual ,expected ,actual)))
|
155
|
+
|
156
|
+
(defmacro assert-nonnil (value)
|
157
|
+
"Assert that VALUE is not nil, or signal a warning."
|
158
|
+
`(unless ,value
|
159
|
+
(elk-test-error "assert-nonnil for <%s> failed: was <%s>"
|
160
|
+
',value ,value)))
|
161
|
+
|
162
|
+
(defmacro assert-t (value)
|
163
|
+
"Assert that VALUE is t, or signal a warning."
|
164
|
+
`(unless (eq ,value t)
|
165
|
+
(elk-test-error "assert-t for <%s> failed: was <%s>"
|
166
|
+
',value ,value)))
|
167
|
+
|
168
|
+
(defmacro assert-nil (value)
|
169
|
+
"Assert that VALUE is nil, or signal a warning."
|
170
|
+
`(when ,value
|
171
|
+
(elk-test-error "assert-nil for <%s> failed: was <%s>"
|
172
|
+
',value ,value)))
|
173
|
+
|
174
|
+
(defmacro assert-error (error-message &rest body)
|
175
|
+
"Assert that BODY raises an `error', or signal a warning.
|
176
|
+
ERROR-MESSAGE is the expected error string, use nil to accept any error. Use
|
177
|
+
nil with caution, as errors like 'wrong-number-of-arguments' (likely caused by
|
178
|
+
typos) will also be caught!"
|
179
|
+
`(let ((elk-test-error
|
180
|
+
(condition-case elk-test-error
|
181
|
+
(progn ,@body)
|
182
|
+
(error (cons 'elk-test-error (cadr elk-test-error))))))
|
183
|
+
(if (not (eq (car elk-test-error) 'elk-test-error))
|
184
|
+
;; no error
|
185
|
+
(elk-test-error "assert-error for <%s> failed: did not raise an error"
|
186
|
+
(append '(progn) ',body))
|
187
|
+
(when (and ,error-message
|
188
|
+
(not (equal ,error-message (cdr elk-test-error))))
|
189
|
+
(elk-test-error (concat "assert-error for <%s> failed: expected <%s>, "
|
190
|
+
"raised <%s>")
|
191
|
+
(append '(progn) ',body)
|
192
|
+
,error-message (cdr elk-test-error))))))
|
193
|
+
|
194
|
+
(defmacro deftest (name &rest body)
|
195
|
+
"Define a test case.
|
196
|
+
Use `assert-equal', `assert-eq', `assert-eql', `assert-nonnil', `assert-t',
|
197
|
+
`assert-nil' and `assert-error' to verify the code."
|
198
|
+
`(progn (unless (gethash ,name elk-test-map)
|
199
|
+
(push ,name elk-test-list))
|
200
|
+
(puthash ,name ',body elk-test-map)
|
201
|
+
,(if elk-test-run-on-define
|
202
|
+
`(run-elk-test ',name ,t)
|
203
|
+
name)))
|
204
|
+
|
205
|
+
(defmacro defsuite (name &rest body)
|
206
|
+
"Define a test suite using a collection of `deftest' forms.
|
207
|
+
The resulting suite can be called with `run-elk-test' and parameter NAME."
|
208
|
+
`(let ((suite
|
209
|
+
(let ((elk-test-map (make-hash-table :test 'equal))
|
210
|
+
(elk-test-list nil))
|
211
|
+
,@body
|
212
|
+
(list 'suite elk-test-map (reverse elk-test-list)))))
|
213
|
+
(unless (gethash ,name elk-test-map)
|
214
|
+
(push ,name elk-test-list))
|
215
|
+
(puthash ,name suite elk-test-map)
|
216
|
+
,(if elk-test-run-on-define
|
217
|
+
`(run-elk-test ,name t)
|
218
|
+
name)))
|
219
|
+
|
220
|
+
(defun build-suite (name &rest tests)
|
221
|
+
"Define a test suite using a collection of test names.
|
222
|
+
The resulting suite can be run by calling `run-elk-test' with parameter NAME."
|
223
|
+
(unless (gethash name elk-test-map)
|
224
|
+
(push name elk-test-list))
|
225
|
+
(puthash name
|
226
|
+
(let ((map (make-hash-table :test 'equal))
|
227
|
+
(list nil))
|
228
|
+
(dolist (test-name tests)
|
229
|
+
(push test-name list)
|
230
|
+
(when (gethash test-name map)
|
231
|
+
(error "Test used twice"))
|
232
|
+
(let ((test (gethash test-name elk-test-map)))
|
233
|
+
(unless test
|
234
|
+
(error "Undefined test <%s>" test-name))
|
235
|
+
(puthash test-name test map)))
|
236
|
+
(list 'suite map (reverse list)))
|
237
|
+
elk-test-map)
|
238
|
+
(if elk-test-run-on-define
|
239
|
+
(run-elk-test "sample suite" t)
|
240
|
+
name))
|
241
|
+
|
242
|
+
(provide 'elk-test)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
;; -*- emacs-lisp -*-
|
2
|
+
;; This program has to be run from the directory it is currently in and
|
3
|
+
;; the rdebug code has to be in the parent directory
|
4
|
+
(load-file "./elk-test.el")
|
5
|
+
|
6
|
+
;; FIXME? Should we use "require 'rdebug" here.
|
7
|
+
;; Would have to prepend . to load-path.
|
8
|
+
(load-file "../rdebug.el")
|
9
|
+
(load-file "../rdebug-annotate.el")
|
10
|
+
|
11
|
+
(defvar last-annotation nil
|
12
|
+
"Value of the last annotation processed")
|
13
|
+
|
14
|
+
;; Redefine functions to make them harmless for testing
|
15
|
+
(defun rdebug-process-annotation (name contents)
|
16
|
+
(setq last-annotation name))
|
17
|
+
|
18
|
+
(make-variable-buffer-local 'gud-rdebug-marker-acc)
|
19
|
+
|
20
|
+
;; -------------------------------------------------------------------
|
21
|
+
;; Test harness for testing the filter.
|
22
|
+
;;
|
23
|
+
|
24
|
+
(require 'advice)
|
25
|
+
|
26
|
+
(defvar rdebug-test-cmd-list '())
|
27
|
+
|
28
|
+
;; Override, partially because tooltip-show doesn't work in batch
|
29
|
+
;; mode, and partially because we collect the output here.
|
30
|
+
(defun tooltip-show (text)
|
31
|
+
(setq rdebug-test-cmd-list (cons text rdebug-test-cmd-list)))
|
32
|
+
|
33
|
+
(defun assert-filter (output str &optional cmd-list)
|
34
|
+
(setq rdebug-test-cmd-list '())
|
35
|
+
(setq gud-marker-acc "")
|
36
|
+
(let ((orig-queue rdebug-call-queue))
|
37
|
+
(let ((real-output (gud-rdebug-marker-filter str)))
|
38
|
+
(assert-equal output real-output)
|
39
|
+
(assert-equal cmd-list (reverse rdebug-test-cmd-list)))
|
40
|
+
|
41
|
+
;;
|
42
|
+
;; Feed the filter one character at a time -- the end result should
|
43
|
+
;; be the same.
|
44
|
+
;;
|
45
|
+
(setq rdebug-test-cmd-list '())
|
46
|
+
(setq gud-marker-acc "")
|
47
|
+
(let ((real-output "")
|
48
|
+
(len (length str))
|
49
|
+
(i 0)
|
50
|
+
(rdebug-call-queue orig-queue))
|
51
|
+
(while (< i len)
|
52
|
+
(setq real-output
|
53
|
+
(concat real-output
|
54
|
+
(gud-rdebug-marker-filter
|
55
|
+
(substring str i (if (equal (+ 1 i) len)
|
56
|
+
nil
|
57
|
+
(+ 1 i))))))
|
58
|
+
(setq i (+ 1 i)))
|
59
|
+
(assert-equal output real-output)
|
60
|
+
(assert-equal cmd-list (reverse rdebug-test-cmd-list)))))
|
61
|
+
|
62
|
+
|
63
|
+
(deftest "rdebug-filter"
|
64
|
+
;;; (assert-filter "X" "X")
|
65
|
+
;;; (assert-filter "XYZ" "XYZ")
|
66
|
+
;;; (assert-filter "" "\n")
|
67
|
+
;;; (assert-filter "Testing 1 2 3" "Testing 1 2 3")
|
68
|
+
;;; (assert-filter "Testing 1 2 3" "Testing 1 2 3")
|
69
|
+
;;; (assert-filter "ABC" "\
|
70
|
+
;;; breakpoints
|
71
|
+
;;; No breakpoints
|
72
|
+
;;;
|
73
|
+
;;; ABC")
|
74
|
+
|
75
|
+
;; Some systems (read: Mac) echoes the command.
|
76
|
+
(setq rdebug-call-queue '(("pp 100" :tooltip)))
|
77
|
+
(assert-filter "pp 100\n100\n(rdb:1) " "\
|
78
|
+
prompt
|
79
|
+
pp 100\n100
|
80
|
+
pre-prompt
|
81
|
+
\(rdb:1) \nprompt\n"
|
82
|
+
'("100\n"))
|
83
|
+
|
84
|
+
;; Some systems don't echo the command.
|
85
|
+
(setq rdebug-call-queue '(("pp 100" :tooltip)))
|
86
|
+
(assert-filter "100\n(rdb:1) " "\
|
87
|
+
prompt
|
88
|
+
100
|
89
|
+
pre-prompt
|
90
|
+
\(rdb:1) \nprompt\n"
|
91
|
+
'("100\n"))
|
92
|
+
)
|
93
|
+
|
94
|
+
|
95
|
+
;; -------------------------------------------------------------------
|
96
|
+
;; Build and run the test suite.
|
97
|
+
;;
|
98
|
+
|
99
|
+
(build-suite "rdebug-suite"
|
100
|
+
"rdebug-filter")
|
101
|
+
|
102
|
+
(run-elk-test "rdebug-suite"
|
103
|
+
"test regular expressions used in tracking lines")
|
@@ -0,0 +1,116 @@
|
|
1
|
+
;; -*- emacs-lisp -*-
|
2
|
+
;; This program has to be run from the directory it is currently in and
|
3
|
+
;; the rdebug code has to be in the parent directory
|
4
|
+
(load-file "./elk-test.el")
|
5
|
+
|
6
|
+
(setq load-path (cons ".." load-path))
|
7
|
+
(require 'rdebug-core)
|
8
|
+
(require 'rdebug-gud)
|
9
|
+
(setq load-path (cdr load-path))
|
10
|
+
|
11
|
+
(defvar last-gud-call nil
|
12
|
+
"Value of the last gud-call")
|
13
|
+
|
14
|
+
;; Redefine functions to make them harmless for testing
|
15
|
+
(defun gud-call (command)
|
16
|
+
(setq last-gud-call command))
|
17
|
+
|
18
|
+
(defun rdebug-call (command)
|
19
|
+
(setq last-gud-call command))
|
20
|
+
|
21
|
+
(deftest "rdebug-goto-frame-test"
|
22
|
+
(let ((buf (generate-new-buffer "testing")))
|
23
|
+
(save-excursion
|
24
|
+
(switch-to-buffer buf)
|
25
|
+
(insert "#0 ERB.result(b#Binding) at line /usr/lib/ruby/1.8/erb.rb:736\n")
|
26
|
+
(insert "#1 Listings.build at line erbtest.rb:24\n")
|
27
|
+
(insert "#2 at line erbtest.rb:33\n")
|
28
|
+
(insert "#10 Listings.build at line erbtest.rb:23")
|
29
|
+
(goto-char (point-min))
|
30
|
+
(setq last-gud-call nil)
|
31
|
+
(setq rdebug-goto-entry-acc "")
|
32
|
+
|
33
|
+
;; --------------------
|
34
|
+
;; The tests
|
35
|
+
|
36
|
+
(rdebug-goto-frame-n-internal "5")
|
37
|
+
(assert-equal nil last-gud-call)
|
38
|
+
(rdebug-goto-frame-n-internal "1")
|
39
|
+
(assert-equal "frame 1" last-gud-call)
|
40
|
+
(rdebug-goto-frame-n-internal "0")
|
41
|
+
(assert-equal "frame 10" last-gud-call))
|
42
|
+
(kill-buffer buf)))
|
43
|
+
|
44
|
+
|
45
|
+
;; -------------------------------------------------------------------
|
46
|
+
;; Check breakpoint toggle commands
|
47
|
+
;;
|
48
|
+
|
49
|
+
(deftest "rdebug-toggle-breakpoints"
|
50
|
+
(let ((buf (generate-new-buffer "*rdebug-breakpoint-test.rb*"))
|
51
|
+
;; Needed by `rdebug-breakpoint-parse-and-update-cache'.
|
52
|
+
(gud-comint-buffer (current-buffer)))
|
53
|
+
(save-excursion
|
54
|
+
(switch-to-buffer buf)
|
55
|
+
(insert "Num Enb What\n")
|
56
|
+
(insert " 1 y at /test.rb:10\n")
|
57
|
+
(insert " 2 n at /test.rb:11\n")
|
58
|
+
(insert " 3 y at /test.rb:12\n")
|
59
|
+
(insert " 4 y at /test.rb:13\n")
|
60
|
+
(rdebug-breakpoint-parse-and-update-cache))
|
61
|
+
(setq gud-target-name "test.rb")
|
62
|
+
|
63
|
+
;; ----------
|
64
|
+
;; Toggle break point
|
65
|
+
(assert-equal 4 (length (rdebug-all-breakpoints)))
|
66
|
+
|
67
|
+
;; ----------
|
68
|
+
;; Toggle break point
|
69
|
+
|
70
|
+
;; Add new.
|
71
|
+
(rdebug-toggle-source-breakpoint "/test.rb" 20)
|
72
|
+
(assert-equal "break /test.rb:20" last-gud-call)
|
73
|
+
;; Delete enabled.
|
74
|
+
(rdebug-toggle-source-breakpoint "/test.rb" 10)
|
75
|
+
(assert-equal "delete 1" last-gud-call)
|
76
|
+
;; Delete disabled.
|
77
|
+
(rdebug-toggle-source-breakpoint "/test.rb" 11)
|
78
|
+
(assert-equal "delete 2" last-gud-call)
|
79
|
+
|
80
|
+
;; ----------
|
81
|
+
;; Toggle enable/disable.
|
82
|
+
|
83
|
+
;; Add new.
|
84
|
+
(rdebug-toggle-source-breakpoint-enabled "/test.rb" 30)
|
85
|
+
(assert-equal "break /test.rb:30" last-gud-call)
|
86
|
+
|
87
|
+
;; Toggle enabled.
|
88
|
+
(rdebug-toggle-source-breakpoint-enabled "/test.rb" 10)
|
89
|
+
(assert-equal "disable 1" last-gud-call)
|
90
|
+
;; Toggle disabled.
|
91
|
+
(rdebug-toggle-source-breakpoint-enabled "/test.rb" 11)
|
92
|
+
(assert-equal "enable 2" last-gud-call)))
|
93
|
+
|
94
|
+
|
95
|
+
;; -------------------------------------------------------------------
|
96
|
+
;; Check rdebug-next with prefix toggling commands
|
97
|
+
;;
|
98
|
+
(deftest "rdebug-stepping-test"
|
99
|
+
(setq rdebug-stepping-prefix "")
|
100
|
+
(assert-equal "next 1" (rdebug-next))
|
101
|
+
(setq rdebug-stepping-prefix "-")
|
102
|
+
(assert-equal "next- 2" (rdebug-next 2))
|
103
|
+
(setq rdebug-stepping-prefix "+")
|
104
|
+
(assert-equal "step+ 1" (rdebug-step))
|
105
|
+
)
|
106
|
+
|
107
|
+
;; -------------------------------------------------------------------
|
108
|
+
;; Build and run the test suite.
|
109
|
+
;;
|
110
|
+
|
111
|
+
(build-suite "rdebug-cmd-suite"
|
112
|
+
"rdebug-goto-frame-test"
|
113
|
+
"rdebug-stepping-test"
|
114
|
+
"rdebug-toggle-breakpoints")
|
115
|
+
(run-elk-test "rdebug-cmd-suite"
|
116
|
+
"test some rdebug-core code")
|