Skip to content

Commit

Permalink
DRY code. Make "make distcheck" work.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jul 1, 2012
1 parent 53acebf commit 593dd3e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SUBDIRS = dbgr
SUBDIRS = dbgr test

lispdir = @lispdir@
lisp_files := $(wildcard dbgr.el)
lisp_LISP = $(lisp_files)

include common.mk

EXTRA_DIST=common.mk README.textile
EXTRA_DIST=common.mk README.textile dbgr.el

if MAINTAINER_MODE

Expand Down
2 changes: 0 additions & 2 deletions dbgr/debugger/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ EXTRA_DIST = common.mk

.PHONY: check all

check:
$(MAKE) -C $(top_srcdir)/test $@
6 changes: 6 additions & 0 deletions test/regexp-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
)

(defun loc-match(text var)
"Match TEXT against regexp field VAR"
(string-match (dbgr-loc-pat-regexp var) text)
)

(defun cmdbuf-loc-match(text dbgr)
"Match TEXT against cmdbuf-info-loc field VAR"
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)

(defun prompt-match(prompt-str &optional num-str fmt-str)
(unless fmt-str (setq fmt-str "debugger prompt %s"))
(assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
Expand Down
18 changes: 7 additions & 11 deletions test/test-loc-regexp-trepan.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(require 'test-simple)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/debugger/trepan/init.el")
(load-file "./regexp-helper.el")

(test-simple-start)

Expand All @@ -17,16 +18,11 @@
:line-group (dbgr-loc-pat-line-group loc-pat)))


(defun loc-match(text)
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)


(setq text "-- (/usr/local/bin/irb:9 @2)")
(assert-t (numberp (loc-match text)) "basic location")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "basic location")

(note "extract file name")
(assert-equal 0 (loc-match text))
(assert-equal 0 (cmdbuf-loc-match text dbgr))
(assert-equal "/usr/local/bin/irb"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text))
Expand All @@ -37,9 +33,9 @@
text) "extract line number")

(setq text "-> (<internal:lib/rubygems/custom_require>:28 remapped /usr/lib/ruby/gems/1.9.1/gems/data/custom_require.rb:28 @2)")
(assert-t (numberp (loc-match text)) "remapped location")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "remapped location")

(assert-equal 0 (loc-match text))
(assert-equal 0 (cmdbuf-loc-match text dbgr))
(assert-equal "/usr/lib/ruby/gems/1.9.1/gems/data/custom_require.rb"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text) "extract remapped file name")
Expand All @@ -50,9 +46,9 @@
text) "extract remapped line number")

(setq text "C> (/tmp/c-func.rb:2)")
(assert-t (numberp (loc-match text)) "basic location for C fn")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "basic location for C fn")

(assert-equal 0 (loc-match text))
(assert-equal 0 (cmdbuf-loc-match text dbgr))
(assert-equal "/tmp/c-func.rb"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text) "extract file name for C fn")
Expand Down
9 changes: 3 additions & 6 deletions test/test-loc-regexp-trepanx.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(require 'test-simple)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/debugger/trepanx/init.el")
(load-file "./regexp-helper.el")

(test-simple-start)

Expand All @@ -18,20 +19,16 @@
:line-group (dbgr-loc-pat-line-group loc-pat)))


(defun loc-match(text)
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)

(defun xagent-match(text)
(string-match (dbgr-loc-pat-regexp xagent-pat) text)
)

(setq text "-- (../rbx-trepanning/tmp/rbxtest.rb:7 @5)")
(assert-t (numberp (loc-match text)) "basic location")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "basic location")

(note "extract file name")
(setq text "-- (../rbx-trepanning/tmp/rbxtest.rb:7 @5)")
(assert-equal 0 (loc-match text))
(assert-equal 0 (cmdbuf-loc-match text dbgr))
(assert-equal "../rbx-trepanning/tmp/rbxtest.rb"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text))
Expand Down
4 changes: 2 additions & 2 deletions test/test-regexp-bashdb.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

(test-simple-start)

(setq prompt-pat (gethash "prompt" dbgr-bashdb-pat-hash))

(note "bashdb prompt matching")
(set (make-local-variable 'prompt-pat)
(gethash "prompt" dbgr-bashdb-pat-hash))
(prompt-match "bashdb<10> " "10")
(prompt-match "bashdb<(5)> " "5" "subshell prompt %s")
(prompt-match "bashdb<<1>> " "1" "nested debug prompt %s")
Expand Down
12 changes: 7 additions & 5 deletions test/test-regexp-gdb.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(require 'test-simple)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/debugger/gdb/init.el")
(load-file "./regexp-helper.el")

(test-simple-start)

Expand All @@ -22,11 +23,7 @@
(setq text "/home/rocky/c/ctest.c:80:2000:beg:0x8048748>")
(note "traceback location matching")

(defun loc-match(text)
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)

(assert-t (numberp (loc-match text)) "basic location")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "basic location")
(assert-equal "/home/rocky/c/ctest.c"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text) "extract file name")
Expand Down Expand Up @@ -93,5 +90,10 @@
(match-beginning line-group)
(match-end line-group)))

(note "prompt")
(set (make-local-variable 'prompt-pat)
(gethash "prompt" dbgr-gdb-pat-hash))
(prompt-match "(gdb) ")

(end-tests)

17 changes: 7 additions & 10 deletions test/test-regexp-perldb.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,28 @@
; We customize this for this debugger.
; FIXME: encapsulate this.
(setq dbg-name "perldb")
(setq loc-pat (gethash "loc" (gethash dbg-name dbgr-pat-hash)))
(setq prompt-pat (gethash "prompt" dbgr-perldb-pat-hash))
(set (make-local-variable 'loc-pat)
(gethash "loc" (gethash dbg-name dbgr-pat-hash)))
(set (make-local-variable 'prompt-pat)
(gethash "prompt" dbgr-perldb-pat-hash))

(setq dbgr (make-dbgr-cmdbuf-info
:debugger-name dbg-name
:loc-regexp (dbgr-loc-pat-regexp loc-pat)
:file-group (dbgr-loc-pat-file-group loc-pat)
:line-group (dbgr-loc-pat-line-group loc-pat)))


(note "prompt")
(prompt-match " DB<2> " "2")
(prompt-match "[pid=6489->6502] DB<1> " "1")
(prompt-match "[pid=6489->6502] DB<1> " "1")

(assert-equal 0 (string-match dbgr-perl-ignore-file-re
"(eval 1006)[../example/eval.pl:5]")
"perldb file ignore matching")

(defun loc-match(text)
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)

(setq text "main::(/usr/bin/latex2html:102):")

(assert-t (numberp (loc-match text)) "basic location")
(assert-t (numberp (cmdbuf-loc-match text dbgr)) "basic location")
(assert-equal "/usr/bin/latex2html"
(match-string (dbgr-cmdbuf-info-file-group dbgr) text)
"extract file name")
Expand All @@ -44,7 +41,7 @@

(note "location for with CODE in it")
(setq text "main::CODE(0x9407ac8)(l2hconf.pm:6):")
(assert-t (numberp (loc-match text)))
(assert-t (numberp (cmdbuf-loc-match text dbgr)))
(assert-equal "l2hconf.pm"
(match-string (dbgr-cmdbuf-info-file-group dbgr)
text))
Expand Down
5 changes: 5 additions & 0 deletions test/test-regexp-rdebug.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@
text) "extract breakpoint line number")
)

(note "prompt")
(set (make-local-variable 'prompt-pat)
(gethash "prompt" dbgr-rdebug-pat-hash))
(prompt-match "(rdb:1) ")

(end-tests)
2 changes: 1 addition & 1 deletion test/test-regexp-remake.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

(note "remake prompt")
(prompt-match "remake<10> " "10")
(prompt-match "remake<<1>> " "1")
(prompt-match "remake<<1>> " "1" "recursive remake %s")

(note "remake debugger-backtrace")
(setq s1
Expand Down

0 comments on commit 593dd3e

Please sign in to comment.