[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0d00b35 8/8: Add 'packages/realgud-node-inspect/' from com
From: |
Rocky Bernstein |
Subject: |
[elpa] master 0d00b35 8/8: Add 'packages/realgud-node-inspect/' from commit '1cec9aecba5d31dfa419d7e73a38f101c3447a21' |
Date: |
Mon, 20 May 2019 07:33:33 -0400 (EDT) |
branch: master
commit 0d00b35011a5a8dcc4e040dbc67c72477c2b73a5
Merge: c32288b 1cec9ae
Author: rocky <address@hidden>
Commit: rocky <address@hidden>
Add 'packages/realgud-node-inspect/' from commit
'1cec9aecba5d31dfa419d7e73a38f101c3447a21'
git-subtree-dir: packages/realgud-node-inspect
git-subtree-mainline: c32288bd69141bb40dacadc36122e8dd9fd342fb
git-subtree-split: 1cec9aecba5d31dfa419d7e73a38f101c3447a21
---
packages/realgud-node-inspect/.gitignore | 21 +++
packages/realgud-node-inspect/INSTALL.md | 5 +
packages/realgud-node-inspect/Makefile.am | 49 ++++++
packages/realgud-node-inspect/README.md | 6 +
packages/realgud-node-inspect/autogen.sh | 12 ++
packages/realgud-node-inspect/common.mk | 24 +++
packages/realgud-node-inspect/common.mk.in | 24 +++
packages/realgud-node-inspect/compute-lispdir.sh | 46 +++++
packages/realgud-node-inspect/configure.ac | 55 ++++++
.../realgud-node-inspect/realgud-node-inspect.el | 52 ++++++
.../realgud-node-inspect/.nosearch | 8 +
.../realgud-node-inspect/Makefile.am | 5 +
.../realgud-node-inspect/core.el | 172 +++++++++++++++++++
.../realgud-node-inspect/init.el | 188 +++++++++++++++++++++
.../realgud-node-inspect/main.el | 84 +++++++++
.../realgud-node-inspect/track-mode.el | 84 +++++++++
packages/realgud-node-inspect/test/Makefile.am | 70 ++++++++
packages/realgud-node-inspect/test/gcd.js | 45 +++++
.../realgud-node-inspect/test/make-check-filter.rb | 24 +++
.../realgud-node-inspect/test/regexp-helper.el | 50 ++++++
.../test/test-loc-regexp-node-inspect.el | 118 +++++++++++++
.../realgud-node-inspect/test/test-node-inspect.el | 37 ++++
22 files changed, 1179 insertions(+)
diff --git a/packages/realgud-node-inspect/.gitignore
b/packages/realgud-node-inspect/.gitignore
new file mode 100644
index 0000000..1e2b8ab
--- /dev/null
+++ b/packages/realgud-node-inspect/.gitignore
@@ -0,0 +1,21 @@
+*.elc
+*~
+/*-pkg.el
+/*.tar.gz
+/README
+/aclocal.m4
+/autom4te.cache
+/config.log
+/config.status
+/configure
+/configure.lineno
+/elpa
+/install-sh
+/missing
+/test/npm-debug.log
+/tmp
+Makefile
+Makefile.in
+elc-stamp
+elc-temp
+script
diff --git a/packages/realgud-node-inspect/INSTALL.md
b/packages/realgud-node-inspect/INSTALL.md
new file mode 100644
index 0000000..4d46fae
--- /dev/null
+++ b/packages/realgud-node-inspect/INSTALL.md
@@ -0,0 +1,5 @@
+* Have `realgud` installed.
+* From inside emacs, evaluate:
+```lisp
+ (compile (format "EMACSLOADPATH=:%s:%s ./autogen.sh" (file-name-directory
(locate-library "test-simple.elc")) (file-name-directory (locate-library
"realgud.elc"))))
+```
diff --git a/packages/realgud-node-inspect/Makefile.am
b/packages/realgud-node-inspect/Makefile.am
new file mode 100644
index 0000000..1878250
--- /dev/null
+++ b/packages/realgud-node-inspect/Makefile.am
@@ -0,0 +1,49 @@
+# Note: This makefile include remake-style target comments.
+# These comments before the targets start with #:
+# remake --tasks to shows the targets and the comments
+
+SUBDIRS = realgud-node-inspect test
+
+GIT2CL ?= git2cl
+RUBY ?= ruby
+
+lispdir = @lispdir@
+
+lisp_files = $(wildcard *.el)
+lisp_LISP = $(lisp_files)
+include common.mk
+
+PHONY=check clean dist distclean test check-short check-terse install-short
+
+EXTRA_DIST=common.mk.in README.md THANKS $(lisp_files) test/gcd.rb
+
+if MAINTAINER_MODE
+
+#: Remove change log: ChangeLog
+rmChangeLog:
+ rm ChangeLog || true
+
+#: Create a ChangeLog file from git logs
+ChangeLog: rmChangeLog
+ git log --pretty --numstat --summary | $(GIT2CL) > $@
+
+ACLOCAL_AMFLAGS=-I .
+
+endif
+
+#: Run all tests
+test: check
+
+#: Run all tests without bloated output
+check-short:
+ $(MAKE) check 2>&1 | $(RUBY) test/make-check-filter.rb
+
+#: Run all tests without and show just the failure lines
+check-terse:
+ $(MAKE) check 2>&1 | $(RUBY) tes/make-check-filter.rb | grep failure
+
+#: Run "make install"
+install-short:
+ $(MAKE) install 2>&1 | $(RUBY) test/make-check-filter.rb
+
+.PHONY: test check check-short rmChangeLog
diff --git a/packages/realgud-node-inspect/README.md
b/packages/realgud-node-inspect/README.md
new file mode 100644
index 0000000..5ab2126
--- /dev/null
+++ b/packages/realgud-node-inspect/README.md
@@ -0,0 +1,6 @@
+Module to add [node inspect](https://nodejs.org/api/debugger.html)'s
[V8-inspector-protocol](https://chromedevtools.github.io/devtools-protocol/v8/Debugger)
+debugger support to emacs
+[realgud](http://github.com/realgud/realgud).
+
+Note: for node before version 6.3, an older protocol is used. In realgud,
+that debugger for the older version is called `node-debug`.
diff --git a/packages/realgud-node-inspect/autogen.sh
b/packages/realgud-node-inspect/autogen.sh
new file mode 100755
index 0000000..7beb4b9
--- /dev/null
+++ b/packages/realgud-node-inspect/autogen.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# An autoconf setup script.
+# From inside emacs, make sure test-simple is installed and then
+# Press C-x C-e at the end of the next line run this script
+# (test-simple-run "EMACSLOADPATH=%s ./autogen.sh" (mapconcat 'identity
load-path ":"))
+ln -fs README.md README
+touch common.mk
+autoreconf -vfi && \
+autoconf && {
+ echo "Running configure with --enable-maintainer-mode $@"
+ ./configure --enable-maintainer-mode $@
+}
diff --git a/packages/realgud-node-inspect/common.mk
b/packages/realgud-node-inspect/common.mk
new file mode 100644
index 0000000..36fbedc
--- /dev/null
+++ b/packages/realgud-node-inspect/common.mk
@@ -0,0 +1,24 @@
+MOSTLYCLEANFILES = *.elc
+EMACSLOADPATH=:/home/rocky/.emacs.d/elpa/test-simple-20170527.1532/:/home/rocky/.emacs.d/elpa/realgud-20190504.1238/:/home/rocky/.emacs.d/elpa/load-relative-20170526.1010/:/home/rocky/.emacs.d/elpa/loc-changes-20160801.1708/
+
+short:
+ $(MAKE) 2>&1 >/dev/null | ruby $(top_srcdir)/make-check-filter.rb
+
+%.short:
+ $(MAKE) $(@:.short=) 2>&1 >/dev/null
+
+# This is the default rule, but we need to include an EMACLOADPATH
+.el.elc:
+ if test "$(EMACS)" != "no"; then \
+ am__dir=. am__subdir_includes=''; \
+ case $@ in */*) \
+ am__dir=`echo '$@' | sed 's,/[^/]*$$,,'`; \
+ am__subdir_includes="-L $$am__dir -L $(srcdir)/$$am__dir"; \
+ esac; \
+ test -d "$$am__dir" || $(MKDIR_P) "$$am__dir" || exit 1; \
+ EMACSLOADPATH=$(EMACSLOADPATH) $(EMACS) --batch \
+ $(AM_ELCFLAGS) $(ELCFLAGS) \
+ $$am__subdir_includes -L $(builddir) -L $(srcdir) \
+ --eval "(defun byte-compile-dest-file (f) \"address@hidden")" \
+ --eval "(unless (byte-compile-file \"$<\") (kill-emacs 1))"; \
+ else :; fi
diff --git a/packages/realgud-node-inspect/common.mk.in
b/packages/realgud-node-inspect/common.mk.in
new file mode 100644
index 0000000..c28f493
--- /dev/null
+++ b/packages/realgud-node-inspect/common.mk.in
@@ -0,0 +1,24 @@
+MOSTLYCLEANFILES = *.elc
address@hidden@
+
+short:
+ $(MAKE) 2>&1 >/dev/null | ruby $(top_srcdir)/make-check-filter.rb
+
+%.short:
+ $(MAKE) $(@:.short=) 2>&1 >/dev/null
+
+# This is the default rule, but we need to include an EMACLOADPATH
+.el.elc:
+ if test "$(EMACS)" != "no"; then \
+ am__dir=. am__subdir_includes=''; \
+ case $@ in */*) \
+ am__dir=`echo '$@' | sed 's,/[^/]*$$,,'`; \
+ am__subdir_includes="-L $$am__dir -L $(srcdir)/$$am__dir"; \
+ esac; \
+ test -d "$$am__dir" || $(MKDIR_P) "$$am__dir" || exit 1; \
+ EMACSLOADPATH=$(EMACSLOADPATH) $(EMACS) --batch \
+ $(AM_ELCFLAGS) $(ELCFLAGS) \
+ $$am__subdir_includes -L $(builddir) -L $(srcdir) \
+ --eval "(defun byte-compile-dest-file (f) \"address@hidden")" \
+ --eval "(unless (byte-compile-file \"$<\") (kill-emacs 1))"; \
+ else :; fi
diff --git a/packages/realgud-node-inspect/compute-lispdir.sh
b/packages/realgud-node-inspect/compute-lispdir.sh
new file mode 100755
index 0000000..220befd
--- /dev/null
+++ b/packages/realgud-node-inspect/compute-lispdir.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Figures out a reasonable --prefix
+typeset -i rc=0
+typeset -i DEBUG=${DEBUG:-0}
+EMACS_PROG=${EMACS_PROG:-emacs}
+list=$($EMACS_PROG --batch --no-splash --no-site-file --eval '(message
(substring (format "%s" load-path) 1 -1))' 2>&1)
+rc=$?
+if (( rc != 0 )) ; then
+ echo >&2 "Something went wrong running $EMACS_PROG"
+ exit $rc
+$cmd
+fi
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/site-lisp)
+ ((DEBUG)) && echo "site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+exit 0
diff --git a/packages/realgud-node-inspect/configure.ac
b/packages/realgud-node-inspect/configure.ac
new file mode 100644
index 0000000..7a672b0
--- /dev/null
+++ b/packages/realgud-node-inspect/configure.ac
@@ -0,0 +1,55 @@
+dnl FIXME: pick up from realgud.el
+AC_INIT(realgud-inspect, 1.0.0,)
+AC_CONFIG_SRCDIR(realgud-node-inspect/main.el)
+AM_INIT_AUTOMAKE([foreign])
+AM_MAINTAINER_MODE
+
+AC_PATH_PROG([EMACS], [emacs], [emacs])
+AC_ARG_WITH(emacs, AC_HELP_STRING([--with-emacs],
+ [location of emacs program]), EMACS=$withval)
+
+AC_MSG_NOTICE("Checking emacs version")
+$EMACS -batch -q --no-site-file -eval \
+ '(if (<= emacs-major-version 23)
+ (progn
+ (error "You need GNU Emacs 24 or better.")
+ (kill-emacs 1)
+ )
+ )'
+if test $? -ne 0 ; then
+ AC_MSG_ERROR([Can't continue until above error is corrected.])
+fi
+
+##################################################################
+# See if --with-lispdir was set. If not, set it to a reasonable default
+# based on where bash thinks bashdb is supposed to be installed.
+##################################################################
+
+AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir)
+
+# Check whether --with-lispdir was given.
+if test "${with_lispdir+set}" = set; then :
+else
+ my_lispdir=$(EMACS_PROG=$EMACS $SH_PROG $(dirname $0)/compute-lispdir.sh)
+ if test "${my_lispdir+set}" = set; then :
+ with_lispdir=$my_lispdir
+ echo "'compute-lispdir.sh' lispdir install directory override:
'$with_lispdir'"
+ fi
+fi
+
+##
+## Find out where to install the debugger emacs lisp files
+##
+AM_PATH_LISPDIR
+lispdir_realgud=$lispdir/realgud
+AC_SUBST([lispdir])
+AC_SUBST([lispdir_realgud])
+
+AM_CONDITIONAL(INSTALL_EMACS_LISP, test "x$lispdir_realgud" != "x")
+
+AC_CONFIG_FILES([Makefile \
+ common.mk \
+ realgud-node-inspect/Makefile \
+ test/Makefile \
+ ])
+AC_OUTPUT
diff --git a/packages/realgud-node-inspect/realgud-node-inspect.el
b/packages/realgud-node-inspect/realgud-node-inspect.el
new file mode 100644
index 0000000..383a6d5
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect.el
@@ -0,0 +1,52 @@
+;;; realgud-node-inspect.el --- Realgud front-end to newer "node inspect" -*-
lexical-binding: t -*-
+
+;; Author: Rocky Bernstein
+;; Version: 1.0.0
+;; Package-Type: multi
+;; Package-Requires: ((realgud "1.4.5") (load-relative "1.2") (cl-lib "0.5")
(emacs "24"))
+;; URL: http://github.com/realgud/realgud-node-inspect
+;; Compatibility: GNU Emacs 24.x
+
+;; Copyright (C) 2019 Free Software Foundation, Inc
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; realgud support for the "node inspect" with V8 inspector support.
+;; See https://nodejs.org/api/debugger.html
+;;
+;; Note: for node before version 6.3, an older protocol is used. In
+;; realgud, that debugger for the older version is called
+;; `node-debug`.
+;;
+;;; Code:
+
+;; Press C-x C-e at the end of the next line configure the program in
+;; for building via "make" to get set up.
+;; (compile (format "EMACSLOADPATH=:%s:%s:%s:%s ./autogen.sh"
(file-name-directory (locate-library "test-simple.elc")) (file-name-directory
(locate-library "realgud.elc")) (file-name-directory (locate-library
"load-relative.elc")) (file-name-directory (locate-library "loc-changes.elc"))))
+(require 'load-relative)
+
+(defgroup realgud-node-inspector nil
+ "Realgud interface to the 'node inspect' debugger"
+ :group 'realgud
+ :version "24.3")
+
+(require-relative-list '( "./realgud-node-inspect/main" ) "realgud-")
+(load-relative "./realgud-node-inspect/main.el")
+(load-relative "./realgud-node-inspect/track-mode.el")
+
+(provide-me)
+
+;;; realgud-node-inspect.el ends here
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/.nosearch
b/packages/realgud-node-inspect/realgud-node-inspect/.nosearch
new file mode 100644
index 0000000..97f36a7
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/.nosearch
@@ -0,0 +1,8 @@
+site-lisp directories and their subdirectories may be automatically
+added to load path, in particular in Debian
+/usr/local/share/emacs/site-lisp/ is added to load-path before emacs
+system directories. So realgud-node-inspect's common/buffer/info.el is loaded
+before emacs's info.el
+
+Adding this ".nosearch" file prevents emacs from adding realgud-node-inspect
to the
+load-path.
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/Makefile.am
b/packages/realgud-node-inspect/realgud-node-inspect/Makefile.am
new file mode 100644
index 0000000..aa624b8
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/Makefile.am
@@ -0,0 +1,5 @@
+lisp_files = $(wildcard *.el)
+EXTRA_DIST=$(lisp_files)
+lisp_LISP = $(lisp_files)
+include ../common.mk
+lispdir = @lispdir@/node-inspect
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/core.el
b/packages/realgud-node-inspect/realgud-node-inspect/core.el
new file mode 100644
index 0000000..27ee471
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/core.el
@@ -0,0 +1,172 @@
+;; Copyright (C) 2019 Free Software Foundation, Inc
+;; Author: Rocky Bernstein
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(eval-when-compile (require 'cl-lib))
+
+(require 'realgud)
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:node-inspect-minibuffer-history nil
+ "Minibuffer history list for the command `node-inspect'.")
+
+(easy-mmode-defmap realgud:node-inspect-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of node-inspect startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun node-inspect-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:node-inspect-suggest-invocation
+ realgud:node-inspect-minibuffer-local-map
+ 'realgud:node-inspect-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun node-inspect-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+* the name of the debugger given (e.g. node-inspect) and its arguments ,
+ a list of strings
+* the script name and its arguments - list of strings
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(node --interactive --debugger-port 5858 /tmp node-inspect ./gcd.js a b))
+
+we might return:
+ ((\"node\" \"--interactive\" \"--debugger-port\" \"5858\") nil
+ (\"/tmp/gcd.js\" \"a\" \"b\"))
+
+Note that path elements have been expanded via `expand-file-name'."
+
+ ;; Parse the following kind of pattern:
+ ;; node node-inspect-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (node-two-args '("-debugger_port" "C" "D" "i" "l" "m" "-module" "x"))
+ ;; node doesn't have any optional two-arg options
+ (node-opt-two-args '())
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -debugger_port is really --debugger_port.
+ (node-inspect-two-args '("-debugger_port"))
+ (node-inspect-opt-two-args '())
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ )
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil, nil)
+ (list interpreter-args nil script-args)
+ ;; else
+ (progn
+ ;; Remove "node-inspect" (or "nodemon" or "node") from invocation like:
+ ;; node-inspect --node-inspect-options script --script-options
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^node\\(?:js\\|mon\\)?$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `node', `nodemon', or
`node-inspect'"
+ debugger-name))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ((equal "debug" arg)
+ (nconc interpreter-args (list arg))
+ (setq args (cdr args))
+ )
+
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args node-inspect-two-args node-inspect-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args nil script-args)))
+ ))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:node-inspect-command-name)
+
+(defun realgud:node-inspect-suggest-invocation (debugger-name)
+ "Suggest a node-inspect command invocation via `realgud-suggest-invocaton'."
+ (realgud-suggest-invocation realgud:node-inspect-command-name
+ realgud:node-inspect-minibuffer-history
+ "js" "\\.js$"))
+
+(defun realgud:node-inspect-remove-ansi-shmutz()
+ "Remove ASCII escape sequences that node.js 'decorates' in
+prompts and interactive output."
+ (add-to-list
+ 'comint-preoutput-filter-functions
+ (lambda (output)
+ (replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output)))
+ )
+
+(defun realgud:node-inspect-reset ()
+ "Node-Inspect cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (node-inspect-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*node-inspect-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun node-inspect-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'node-inspect-debugger-support-minor-mode
minor-mode-map-alist)
+;; node-inspect-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:node-inspect-customize ()
+ "Use `customize' to edit the settings of the `node-inspect' debugger."
+ (interactive)
+ (customize-group 'realgud:node-inspect))
+
+(provide-me "realgud:node-inspect-")
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/init.el
b/packages/realgud-node-inspect/realgud-node-inspect/init.el
new file mode 100644
index 0000000..a206378
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/init.el
@@ -0,0 +1,188 @@
+;; Copyright (C) 2019 Free Software Foundation, Inc
+;; Author: Rocky Bernstein
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; "node inspect" debugger
+
+(eval-when-compile (require 'cl-lib)) ;For setf.
+
+(require 'realgud)
+(require 'realgud-lang-js)
+(require 'ansi-color)
+
+(defvar realgud:node-inspect-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:node-inspect-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; before a command prompt.
+;; For example:
+;; break in /home/indutny/Code/git/indutny/myscript.js:1
+(setf (gethash "loc" realgud:node-inspect-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format
+ "\\(?:%s\\)*\\(?:break\\|exception\\|Break on start\\) in
\\(?:file://\\)?%s:%s"
+ realgud:js-term-escape "\\([^:]+\\)"
+ realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes a node-inspect command prompt
+;; For example:
+;; debug>
+(setf (gethash "prompt" realgud:node-inspect-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^\\(?:%s\\)*debug> " realgud:js-term-escape)
+ ))
+
+;; Need an improved setbreak for this.
+;; ;; Regular expression that describes a "breakpoint set" line
+;; ;; 3 const armlet = require('armlet');
+;; ;; * 4 const client = new armlet.Client(
+;; ;; ^^^^
+;; ;;
+;; (setf (gethash "brkpt-set" realgud:node-inspect-pat-hash)
+;; (make-realgud-loc-pat
+;; :regexp "^\*[ ]*\\([0-9]+\\) \\(.+\\)"
+;; :line-group 1
+;; :text-group 2))
+
+;; Regular expression that describes a V8 backtrace line.
+;; For example:
+;; at repl:1:7
+;; at Interface.controlEval
(/src/external-vcs/github/trepanjs/lib/interface.js:352:18)
+;; at REPLServer.b [as eval] (domain.js:183:18)
+(setf (gethash "lang-backtrace" realgud:node-inspect-pat-hash)
+ realgud:js-backtrace-loc-pat)
+
+;; Regular expression that describes a debugger "delete" (breakpoint)
+;; response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:node-inspect-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Removed %s breakpoint(s).\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+
+(defconst realgud:node-inspect-frame-start-regexp "\\(?:^\\|\n\\)\\(?:#\\)")
+(defconst realgud:node-inspect-frame-num-regexp realgud:regexp-captured-num)
+(defconst realgud:node-inspect-frame-module-regexp "[^ \t\n]+")
+(defconst realgud:node-inspect-frame-file-regexp "[^ \t\n]+")
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; #0 module.js:380:17
+;; #1 dbgtest.js:3:9
+;; #2 Module._compile module.js:456:26
+;;
+;; and with a newer node inspect:
+;;
+;; #0 file:///tmp/module.js:380:17
+;; #1 file:///tmp/dbgtest.js:3:9
+;; #2 Module._compile file:///tmpmodule.js:456:26
+(setf (gethash "debugger-backtrace" realgud:node-inspect-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "%s%s\\(?: %s\\)?
\\(?:file://\\)?\\(%s\\):%s:%s"
+ realgud:node-inspect-frame-start-regexp
+ realgud:node-inspect-frame-num-regexp
+ realgud:node-inspect-frame-module-regexp
+ realgud:node-inspect-frame-file-regexp
+ realgud:regexp-captured-num
+ realgud:regexp-captured-num
+ )
+ :num 1
+ :file-group 2
+ :line-group 3
+ :char-offset-group 4))
+
+(defconst realgud:node-inspect-debugger-name "node-inspect" "Name of
debugger.")
+
+;; ;; Regular expression that for a termination message.
+;; (setf (gethash "termination" realgud:node-inspect-pat-hash)
+;; "^node-inspect: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:node-inspect-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --^-
+ ("^\\(->\\|##\\)\\([0-9]+\\) "
+ (2 realgud-backtrace-number-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; ---------^^^^^^^^^^^^^^^^^^^^-
+ ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
+ (2 realgud-file-name-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --------^^
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ))
+
+(setf (gethash "node-inspect" realgud-pat-hash)
+ realgud:node-inspect-pat-hash)
+
+;; Prefix used in variable names (e.g. short-key-mode-map) for
+;; this debugger
+
+(setf (gethash "node-inspect" realgud:variable-basename-hash)
+ "realgud:node-inspect")
+
+(defvar realgud:node-inspect-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'finish' and the value is
+the node-inspect command to use, like 'out'.")
+
+(setf (gethash realgud:node-inspect-debugger-name
+ realgud-command-hash)
+ realgud:node-inspect-command-hash)
+
+(setf (gethash "backtrace" realgud:node-inspect-command-hash)
"backtrace")
+(setf (gethash "break" realgud:node-inspect-command-hash)
+ "setBreakpoint('%X',%l)")
+(setf (gethash "clear" realgud:node-inspect-command-hash)
+ "clearBreakpoint('%X', %l)")
+(setf (gethash "continue" realgud:node-inspect-command-hash) "cont")
+(setf (gethash "eval" realgud:node-inspect-command-hash)
"exec('%s')")
+(setf (gethash "finish" realgud:node-inspect-command-hash) "out")
+(setf (gethash "info-breakpoints" realgud:node-inspect-command-hash)
"breakpoints")
+(setf (gethash "kill" realgud:node-inspect-command-hash) "kill")
+(setf (gethash "quit" realgud:node-inspect-command-hash) ".exit")
+(setf (gethash "shell" realgud:node-inspect-command-hash) "repl")
+
+;; We need aliases for step and next because the default would
+;; do step 1 and node-inspect doesn't handle this. And if it did,
+;; it would probably look like step(1).
+(setf (gethash "step" realgud:node-inspect-command-hash) "step")
+(setf (gethash "next" realgud:node-inspect-command-hash) "next")
+
+;; Unsupported features:
+(setf (gethash "jump" realgud:node-inspect-command-hash)
"*not-implemented*")
+(setf (gethash "up" realgud:node-inspect-command-hash)
"*not-implemented*")
+(setf (gethash "down" realgud:node-inspect-command-hash)
"*not-implemented*")
+(setf (gethash "frame" realgud:node-inspect-command-hash)
"*not-implemented*")
+
+(setf (gethash "node-inspect" realgud-command-hash)
realgud:node-inspect-command-hash)
+(setf (gethash "node-inspect" realgud-pat-hash) realgud:node-inspect-pat-hash)
+
+(provide-me "realgud:node-inspect-")
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/main.el
b/packages/realgud-node-inspect/realgud-node-inspect/main.el
new file mode 100644
index 0000000..d511886
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/main.el
@@ -0,0 +1,84 @@
+;; Copyright (C) 2016, 2018-2019 Rocky Bernstein
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `realgud:node-inspect' Main interface to "node inspect" debugger via Emacs
+
+(require 'cl-lib)
+(require 'load-relative)
+(require 'realgud)
+(require-relative-list '("core" "track-mode") "realgud:node-inspect-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:node-inspect nil
+ "The realgud interface to the node-inspect debugger"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:node-inspect-command-name
+ "node inspect"
+ "File name for executing the Javascript debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:node-inspect)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function node-inspect-track-mode 'realgud-node-inspect-track-mode)
+(declare-function node-inspect-query-cmdline 'realgud:node-inspect-core)
+(declare-function node-inspect-parse-cmd-args 'realgud:node-inspect-core)
+
+;;;###autoload
+(defun realgud:node-inspect (&optional opt-cmd-line no-reset)
+ "Invoke the node-inspect shell debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run node-inspect.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `node-inspect-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons."
+ (interactive)
+ (let ((cmd-buf
+ (realgud:run-debugger "node-inspect"
+ 'node-inspect-query-cmdline
'node-inspect-parse-cmd-args
+ 'realgud:node-inspect-minibuffer-history
+ opt-cmd-line no-reset)))
+ ;; (if cmd-buf
+ ;; (with-current-buffer cmd-buf
+ ;; ;; FIXME should allow customization whether to do or not
+ ;; ;; and also only do if hook is not already there.
+ ;; (realgud:remove-ansi-schmutz)
+ ;; )
+ ;; )
+ ))
+
+(defalias 'node-inspect 'realgud:node-inspect)
+
+(provide-me "realgud-")
diff --git a/packages/realgud-node-inspect/realgud-node-inspect/track-mode.el
b/packages/realgud-node-inspect/realgud-node-inspect/track-mode.el
new file mode 100644
index 0000000..0640bae
--- /dev/null
+++ b/packages/realgud-node-inspect/realgud-node-inspect/track-mode.el
@@ -0,0 +1,84 @@
+;;; track-mode.el ---
+;; Copyright (C) 2019 Free Software Foundation, Inc
+;; Author: Rocky Bernstein
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; "node inspect" tracking a comint or eshell buffer.
+
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:remove-ansi-schmutz 'realgud:utils)
+
+(require 'realgud)
+
+(require-relative-list '("core" "init") "realgud:node-inspect-")
+
+(realgud-track-mode-vars "realgud:node-inspect")
+
+(defun realgud:node-inspect-track-mode-hook()
+ (if realgud:node-inspect-track-mode
+ (progn
+ (use-local-map realgud:node-inspect-track-mode-map)
+ (realgud:remove-ansi-schmutz)
+ (message "using node-inspect mode map")
+ )
+ (message "node-inspect track-mode-hook disable called"))
+)
+
+;; FIXME: this shouldn't be needed
+(defvar realgud:node-inspect-track-mode-map (make-keymap))
+(define-key realgud:node-inspect-track-mode-map
+ (kbd "C-c !f") 'realgud:js-goto-file-line)
+
+(define-minor-mode realgud:node-inspect-track-mode
+ "Minor mode for tracking node-inspect source locations inside a node-inspect
shell via realgud.
+
+If called interactively with no prefix argument, the mode is
+toggled. A prefix argument, captured as ARG, enables the mode if
+the argument is positive, and disables it otherwise.
+
+\\{realgud:node-inspect-track-mode-map}"
+ :init-value nil
+ ;; :lighter " node-inspect" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:node-inspect
+ :keymap realgud:node-inspect-track-mode-map
+
+ (if realgud:node-inspect-track-mode
+ (progn
+ (realgud:track-set-debugger "node-inspect")
+ (realgud:node-inspect-track-mode-hook)
+ (realgud:track-mode-enable))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+ )
+
+;; ;; Debugger commands that node-inspect doesn't have
+;; (define-key node-inspect-track-mode-map
+;; [remap realgud:cmd-newer-frame] 'undefined)
+;; (define-key node-inspect-track-mode-map
+;; [remap realgud:cmd-older-frame] 'undefined)
+(defvar realgud:node-inspect-short-key-mode-map (make-keymap))
+
+(define-key realgud:node-inspect-short-key-mode-map
+ [remap realgud:cmd-step] 'realgud:cmd-step-no-arg)
+(define-key realgud:node-inspect-short-key-mode-map
+ [remap realgud:cmd-step] 'realgud:cmd-step-no-arg)
+(define-key realgud:node-inspect-short-key-mode-map
+ [remap realgud:cmd-next] 'realgud:cmd-next-no-arg)
+
+(provide-me "realgud:node-inspect-")
diff --git a/packages/realgud-node-inspect/test/Makefile.am
b/packages/realgud-node-inspect/test/Makefile.am
new file mode 100644
index 0000000..fbfb2c6
--- /dev/null
+++ b/packages/realgud-node-inspect/test/Makefile.am
@@ -0,0 +1,70 @@
+include $(top_srcdir)/common.mk
+
+PHONY=check test all check-elget test-elget help
+
+#: overall help on running the make targets
+help:
+ @echo "The main function of this Makefile is to facilitate running
tests."
+ @echo
+ @echo "To run all of the tests, use targets \"test\", \"check\" or
\"check-short\"."
+ @echo "For example:"
+ @echo
+ @echo " make check"
+ @echo "or:"
+ @echo " make check-short"
+ @echo
+ @echo "The -short target uses a filter written in Ruby to remove
extreanous output."
+ @echo
+ @echo "To run a specific test like test-srcbuf.el, change \".el\" to"
+ @echo "\".run\". For example:"
+ @echo
+ @echo " make test-srcbuf.run"
+ @echo
+ @echo "Tests can also be run via the Emacs el-get package and this
loads dependent emacs "
+ @echo "package, like load-relative. To do this, use targets,
\"check-elget\","
+ @echo "\"test-elget\", or \"check-short-elget\"."
+ @echo
+ @echo "To run a specific test like test-srcbuf.el via el-get change
\".el\""
+ @echo "to \".elrun\" For example:"
+ @echo
+ @echo " make test-srcbuf.elrun"
+
+
+#: same thing as "check"
+test: check
+
+#: same thing as "check-elget"
+test-elget: check-elget
+
+test_files := $(wildcard test-*.el)
+
+CHECK_FILES = $(notdir $(test_files:.el=.run))
+EL_GET_CHECK_FILES = $(notdir $(test_files:.el=.elrun))
+
+#: Run all tests
+check: $(CHECK_FILES)
+
+#: Run all tests via el-get
+check-elget: $(EL_GET_CHECK_FILES)
+
+#: Run all tests with minimum verbosity
+check-short:
+ $(MAKE) check 2>&1 | ruby ../make-check-filter.rb
+
+#: Run all tests with minimum verbosity via el-get
+check-short-elget:
+ $(MAKE) check-elget 2>&1 | ruby ../make-check-filter.rb
+
+test-%.run:
+ (cd $(top_srcdir)/test && EMACSLOADPATH=$(EMACSLOADPATH) $(EMACS)
--batch --no-site-file --no-splash --load $(@:.run=.el))
+
+#: Run tests using el-get to specify external Lisp dependencies
+test-%.elrun:
+ (cd $(top_srcdir)/test && EMACSLOADPATH=$(EMACSLOADPATH) $(EMACS)
--batch --no-site-file --no-splash --load ../el-get-install.el --load
$(@:.elrun=.el))
+
+install-lispLISP: $(lisp_LISP) $(ELCFILES)
+
+# Whatever it is you want to do, it should be forwarded to the
+# to top-level directories
+# %:
+# $(MAKE) -C .. $@
diff --git a/packages/realgud-node-inspect/test/gcd.js
b/packages/realgud-node-inspect/test/gcd.js
new file mode 100644
index 0000000..ee56555
--- /dev/null
+++ b/packages/realgud-node-inspect/test/gcd.js
@@ -0,0 +1,45 @@
+//!/usr/bin/env node
+var util = require("util");
+require("console");
+
+function ask(question, format, callback) {
+ var stdin = process.stdin, stdout = process.stdout;
+
+ stdin.resume();
+ stdout.write(question + ": ");
+
+ stdin.once('data', function(data) {
+ data = data.toString().trim();
+
+ if (format.test(data)) {
+ callback(data);
+ } else {
+ stdout.write("It should match: "+ format +"\n");
+ ask(question, format, callback);
+ }
+ });
+}
+
+// GCD. We assume positive numbers
+function gcd(a, b) {
+ // Make: a <= b
+ if (a > b) {
+ var temp = a;
+ a = b;
+ b = temp;
+ }
+
+ if (a <= 0) { return null };
+
+ if (a == 1 || b-a == 0) {
+ return a;
+ }
+ return gcd(b-a, a);
+}
+
+var a = parseInt(process.argv[0]) || 24,
+ b = parseInt(process.argv[0]) || 5;
+
+console.log(util.format("The GCD of %d and %d is %d", a, b,
+ gcd(a, b)));
+process.exit();
diff --git a/packages/realgud-node-inspect/test/make-check-filter.rb
b/packages/realgud-node-inspect/test/make-check-filter.rb
new file mode 100644
index 0000000..508c8f6
--- /dev/null
+++ b/packages/realgud-node-inspect/test/make-check-filter.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+# Use this to cut out the crud from make check.
+# Use like this:
+# make check 2>&1 | ruby ../make-check-filter.rb
+# See Makefile.am
+pats = ["^(?:Loading",
+ '(re)?make\[',
+ "Making check in",
+ '\(cd \.\.',
+ "make -C",
+ "Test-Unit",
+ "Fontifying",
+ "`flet'",
+ '\s*$',
+ '##[<>]+$'
+ ].join('|') + ')'
+# puts pats
+skip_re = /#{pats}/
+
+while gets()
+ next if $_.encode!('UTF-8', 'binary',
+ invalid: :replace, undef: :replace, replace: '') =~
skip_re
+ puts $_
+end
diff --git a/packages/realgud-node-inspect/test/regexp-helper.el
b/packages/realgud-node-inspect/test/regexp-helper.el
new file mode 100644
index 0000000..2660077
--- /dev/null
+++ b/packages/realgud-node-inspect/test/regexp-helper.el
@@ -0,0 +1,50 @@
+(require 'test-simple)
+(require 'realgud)
+
+(eval-when-compile
+ (defvar helper-bps)
+ (defvar helper-loc)
+ (defvar helper-tb)
+ (defvar prompt-pat)
+)
+
+(declare-function realgud-loc-pat-regexp 'realgud-backtrace-mode)
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function test-simple-start 'test-simple)
+
+
+(defun setup-regexp-vars(pat-hash)
+ (setq helper-bps (gethash "brkpt-set" pat-hash))
+ (setq helper-loc (gethash "loc" pat-hash))
+ (setq helper-tb (gethash "lang-backtrace" pat-hash))
+)
+
+(defun loc-match(text var)
+ "Match TEXT against regexp field VAR"
+ (string-match (realgud-loc-pat-regexp var) text)
+)
+
+(defun bp-loc-match(text)
+ (string-match (realgud-loc-pat-regexp helper-bps) text)
+)
+
+(defun tb-loc-match(text)
+ (string-match (realgud-loc-pat-regexp helper-tb) text)
+)
+
+(defun cmdbuf-loc-match(text dbgr)
+ "Match TEXT against cmdbuf-info-loc field VAR"
+ (string-match (realgud-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 (realgud-loc-pat-regexp prompt-pat)
+ prompt-str)
+ (format fmt-str prompt-str))
+ (cond (num-str
+ (assert-equal num-str (substring prompt-str
+ (match-beginning 1) (match-end 1))))
+ ('t 't))
+ )
+(provide 'realgud-regexp-helper)
diff --git a/packages/realgud-node-inspect/test/test-loc-regexp-node-inspect.el
b/packages/realgud-node-inspect/test/test-loc-regexp-node-inspect.el
new file mode 100644
index 0000000..3918b7c
--- /dev/null
+++ b/packages/realgud-node-inspect/test/test-loc-regexp-node-inspect.el
@@ -0,0 +1,118 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(require 'realgud)
+
+(load-file "./regexp-helper.el")
+(load-file "../realgud-node-inspect/init.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp-helper)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function test-simple-start 'test-simple)
+(declare-function assert-t 'test-simple)
+(declare-function assert-equal 'test-simple)
+(declare-function note 'test-simple)
+(declare-function end-tests 'test-simple)
+(declare-function realgud-loc-pat-char-offset-group 'realgud:nodejs-init)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar col-group)
+ (defvar test-pos)
+ (defvar bt-re)
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+ (defvar test-s1)
+ (defvar realgud-pat-bt)
+ (defvar realgud:nodejs-pat-hash)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for the debugger trepan. Others may follow.
+; FIXME: encapsulate this.
+(setq dbg-name "nodejs")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:nodejs-pat-hash))
+(setq test-s1
+ "#0 module.js:380:17
+#1 Module._compile module2.js:456:26
+#2 Module._extensions..js module.js:474:10
+#3 Module.load module.js:356:32
+")
+
+(setq bt-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(setq col-group (realgud-loc-pat-char-offset-group realgud-pat-bt))
+(assert-equal 0 (string-match bt-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "module.js"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "380"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(assert-equal "17" (substring test-s1
+ (match-beginning col-group)
+ (match-end col-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 19 (string-match bt-re test-s1 test-pos))
+
+(setq test-s1
+ "#1 Module._compile module2.js:456:26
+#2 Module._extensions..js module.js:474:10
+#3 Module.load module.js:356:32
+")
+(assert-equal 0 (string-match bt-re test-s1))
+
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "module2.js"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "456"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(assert-equal "26" (substring test-s1
+ (match-beginning col-group)
+ (match-end col-group)))
+(setq test-pos (match-end 0))
+(assert-equal 36 test-pos)
+
+(end-tests)
diff --git a/packages/realgud-node-inspect/test/test-node-inspect.el
b/packages/realgud-node-inspect/test/test-node-inspect.el
new file mode 100644
index 0000000..6750d45
--- /dev/null
+++ b/packages/realgud-node-inspect/test/test-node-inspect.el
@@ -0,0 +1,37 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud-node-inspect/main.el")
+
+(eval-when-compile (defvar test:run-process-save))
+
+(declare-function nodejs-parse-cmd-args 'realgud:nodejs)
+(declare-function nodejs 'realgud:nodejs)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuf-history &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "node" debugger-name "debugger name gets passed")
+ (let ((expanded-name (expand-file-name "./gcd.js")))
+ (assert-equal expanded-name script-filename "file name check")
+ ))
+
+(note "node-inspect-parse-cmd-args")
+(assert-equal '(("node") nil ("inspect" "foo"))
+ (node-inspect-parse-cmd-args '("node" "inspect" "foo")))
+
+;; FIXME: need to mock remove-ansi-schmutz in realgud:nodejs
+;; (realgud:nodejs "node inspect ./gcd.js 3 5")
+
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
- [elpa] master updated (c32288b -> 0d00b35), Rocky Bernstein, 2019/05/20
- [elpa] master fe811c0 5/8: Fix up some backtrace regexps, Rocky Bernstein, 2019/05/20
- [elpa] master 6d57325 4/8: Add info-breakpoint; track loc regexp changes, Rocky Bernstein, 2019/05/20
- [elpa] master b6c898d 6/8: Small new package-lint thing., Rocky Bernstein, 2019/05/20
- [elpa] master 73483ba 1/8: Preparation for MELPA release, Rocky Bernstein, 2019/05/20
- [elpa] master 1cec9ae 7/8: Copyright to FSF, Rocky Bernstein, 2019/05/20
- [elpa] master 32817fe 2/8: node-inspect -> realgud-node-inspect ..., Rocky Bernstein, 2019/05/20
- [elpa] master 50926ec 3/8: Add realgud:js-goto-file-line, Rocky Bernstein, 2019/05/20
- [elpa] master 0d00b35 8/8: Add 'packages/realgud-node-inspect/' from commit '1cec9aecba5d31dfa419d7e73a38f101c3447a21',
Rocky Bernstein <=