emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 0dd37e2 053/215: Revise trepanjs regexps and add regexp te


From: Rocky Bernstein
Subject: [elpa] master 0dd37e2 053/215: Revise trepanjs regexps and add regexp test.
Date: Sat, 30 Jul 2016 14:48:53 +0000 (UTC)

branch: master
commit 0dd37e233f315a5666eefc6a3e9fc088fcc6561f
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Revise trepanjs regexps and add regexp test.
---
 realgud/debugger/trepanjs/init.el                  |   14 +++---
 test/test-regexp-nodejs.el                         |    4 +-
 ...st-regexp-nodejs.el => test-regexp-trepanjs.el} |   48 ++++++++++++++------
 3 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/realgud/debugger/trepanjs/init.el 
b/realgud/debugger/trepanjs/init.el
index decb17d..2111c0b 100644
--- a/realgud/debugger/trepanjs/init.el
+++ b/realgud/debugger/trepanjs/init.el
@@ -56,15 +56,19 @@ realgud-loc-pat struct")
 ;;   (trepanjs):
 (setf (gethash "prompt" realgud:trepanjs-pat-hash)
       (make-realgud-loc-pat
-       :regexp "^(+trepanjs)+ "
+       :regexp (format "^\\(?:%s\\)*(+trepanjs)+ " realgud:js-term-escape)
        ))
 
 ;;  Regular expression that describes a "breakpoint set" line
-;; * 4 var count = 0;
+;; For example:
+;;  Breakpoint 2 set in file /tmp/gcd.js, line 2.
+;;  Breakpoint 3 set in file /usr/lib/nodejs/module.js [module.js], line 380.
 (setf (gethash "brkpt-set" realgud:trepanjs-pat-hash)
       (make-realgud-loc-pat
-       :regexp (format "^Breakpoint %s set in file \\(.+\\), line %s.\n"
-                      realgud:regexp-captured-num realgud:regexp-captured-num)
+       :regexp (format "^Breakpoint %s set in file %s, line %s.\n"
+                      realgud:regexp-captured-num
+                      realgud:trepanjs-file-regexp
+                      realgud:regexp-captured-num)
        :num 1
        :file-group 2
        :line-group 3))
@@ -137,8 +141,6 @@ realgud-loc-pat struct")
 ;; We need aliases for step and next because the default would
 ;; do step 1 and trepanjs doesn't handle this. Or when it does,
 ;; it will probably look like step(1)
-(setf (gethash "step"       realgud:trepanjs-command-hash) "step")
-(setf (gethash "next"       realgud:trepanjs-command-hash) "next")
 (setf (gethash "eval"       realgud:trepanjs-command-hash) "eval('%s')")
 
 (provide-me "realgud:trepanjs-")
diff --git a/test/test-regexp-nodejs.el b/test/test-regexp-nodejs.el
index f05fd8a..48cf922 100644
--- a/test/test-regexp-nodejs.el
+++ b/test/test-regexp-nodejs.el
@@ -51,7 +51,7 @@
 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
 (assert-equal "test/fixtures/break-in-module/main.js"
              (match-string (realgud-cmdbuf-info-file-group test-dbgr)
-                           test-text))
+                           test-text) "extract file name")
 
 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
 (assert-equal "1"
@@ -60,7 +60,7 @@
               test-text) "extract line number")
 
 (note "debugger-backtrace")
-(set (make-local-variable 'test-s1)
+(setq test-text
     "#0 module.js:380:17
 ")
 
diff --git a/test/test-regexp-nodejs.el b/test/test-regexp-trepanjs.el
similarity index 62%
copy from test/test-regexp-nodejs.el
copy to test/test-regexp-trepanjs.el
index f05fd8a..b0f5266 100644
--- a/test/test-regexp-nodejs.el
+++ b/test/test-regexp-trepanjs.el
@@ -1,5 +1,5 @@
 (require 'test-simple)
-(load-file "../realgud/debugger/nodejs/init.el")
+(load-file "../realgud/debugger/trepanjs/init.el")
 (load-file "./regexp-helper.el")
 
 (declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
@@ -14,6 +14,7 @@
 (declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
 (declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
 (declare-function __FILE__                       'load-relative)
+(declare-function setup-regexp-vars              'regexp-helper)
 
 (test-simple-start)
 
@@ -22,21 +23,24 @@
   (defvar loc-pat)
   (defvar bt-pat)
   (defvar prompt-pat)
-  (defvar realgud:nodejs-pat-hash)
+  (defvar realgud:trepanjs-pat-hash)
   (defvar realgud-pat-hash)
+  (defvar helper-bps)
   (defvar test-dbgr)
   (defvar test-text)
   (defvar test-s1)
 )
 
-(note "nodejs prompt matching")
+(setup-regexp-vars realgud:trepanjs-pat-hash)
+
+(note "trepanjs prompt matching")
 (set (make-local-variable 'prompt-pat)
-     (gethash "prompt" realgud:nodejs-pat-hash))
-(prompt-match "debug> ")
-(prompt-match "debug> connecting... ok")
+     (gethash "prompt" realgud:trepanjs-pat-hash))
+(prompt-match "(trepanjs) ")
+(prompt-match "(trepanjs) connecting... ok")
 
-(note "nodejs location matching")
-(setq dbg-name "nodejs")
+(note "trepanjs location matching")
+(setq dbg-name "trepanjs")
 (setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
 
 (setq test-dbgr (make-realgud-cmdbuf-info
@@ -45,13 +49,13 @@
                 :file-group (realgud-loc-pat-file-group loc-pat)
                 :line-group (realgud-loc-pat-line-group loc-pat)))
 
-(setq test-text "break in test/fixtures/break-in-module/main.js:1\n")
+(setq test-text "break in test/fixtures/break-in-module/main.js at line 
1:23\n")
 (assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
 
 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
 (assert-equal "test/fixtures/break-in-module/main.js"
              (match-string (realgud-cmdbuf-info-file-group test-dbgr)
-                           test-text))
+                           test-text) "extract file name")
 
 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
 (assert-equal "1"
@@ -59,13 +63,29 @@
               (realgud-cmdbuf-info-line-group test-dbgr)
               test-text) "extract line number")
 
-(note "debugger-backtrace")
-(set (make-local-variable 'test-s1)
-    "#0 module.js:380:17
+(note "breakpoint location matching")
+
+(setq test-text
+      "Breakpoint 2 set in file /tmp/gcd.js, line 2.
 ")
 
+(assert-t (numberp (loc-match test-text helper-bps))
+         "basic breakpoint location")
+(assert-equal "/tmp/gcd.js"
+             (match-string (realgud-loc-pat-file-group helper-bps)
+                           test-text)   "extract breakpoint file name")
+(assert-equal "2"
+             (match-string (realgud-loc-pat-line-group helper-bps)
+                           test-text)
+             "extract breakpoint line number")
+
+(note "debugger-backtrace")
+(setq test-text
+    "##1 in file /tmp/test/gcd.js at line 2:12"
+)
+
 (set (make-local-variable
       'bt-pat)
-      (gethash "debugger-backtrace" realgud:nodejs-pat-hash))
+      (gethash "debugger-backtrace" realgud:trepanjs-pat-hash))
 
 (end-tests)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]