Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async jsonrpc #40

Merged
merged 15 commits into from
Jan 4, 2024
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Install rdbg
run: gem install debug

- name: Install lzip to unpack elpa packages
run: sudo apt install lzip

- name: Build
run: make all

Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
export EMACS ?= $(shell which emacs)

ELFILES = dape.el dape-tests.el
DEPS = jsonrpc-1.0.19/jsonrpc.el

ELFILES = $(DEPS) dape.el dape-tests.el
ELCFILES = $(addsuffix .elc, $(basename $(ELFILES)))

all: $(ELCFILES)

$(DEPS):
@curl "https://elpa.gnu.org/packages/$(@D).tar.lz" -o $(@D).tar.lz
@tar -xvf $(@D).tar.lz
@rm $(@D).tar.lz

%.elc: %.el
@echo Compiling $<
@${EMACS} -batch -q -no-site-file -L . -f batch-byte-compile $<
@${EMACS} -Q -batch -no-site-file -L . -f batch-byte-compile $<

check: $(ELCFILES)
@${EMACS} -batch -l ert $(foreach file, $^, -l $(file)) -f ert-run-tests-batch-and-exit
check: $(DEPS) $(ELCFILES)
@${EMACS} -Q \
-batch \
-l ert \
$(foreach file, $^, -l $(file)) \
-f ert-run-tests-batch-and-exit

clean:
@rm -f *.elc
@rm -fr $(dir $(DEPS))
14 changes: 4 additions & 10 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,8 @@ If you find a working configuration for any other debug adapter please submit a

See [[https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/][microsofts list]] for other adapters, your mileage will vary.

* Roadmap
+ More options for indicator placement
+ Improving completion in REPL
+ Usage of "setVariable" inside of ~*dape-info*~ buffer
+ Improve memory reader with auto reload and write functionality
+ Individual thread controls
+ Variable values displayed in source buffer, this seams to require integration with lsp-mode and eglot

* Bugs and issues
Before reporting any issues take a look at ~*dape-debug*~ buffer with all debug messages enabled.
~(setq dape--debug-on '(io info error std-server))~.
Before reporting any issues take a look at ~*dape-repl*~ buffer.

* Acknowledgements
Big thanks to João Távora for input and of course jsonrpc.
51 changes: 31 additions & 20 deletions dape-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ CONTENT-LIST.
(lambda ,(mapcar 'car buffer-fixtures)
,@body)))

(defvar dape--test-skip-cleanup nil)
(defvar dape-test--skip-cleanup nil
"Skip `dape-test--call-with-files' cleanup.")

(defun dape-test--call-with-files (fixtures fn)
"Setup FIXTURES and apply FN with created buffers.
Expand All @@ -88,21 +89,23 @@ Helper for `dape-test--with-files'."
(setq buffers (nreverse buffers))
(apply fn buffers))
;; reset dape
(unless dape--test-skip-cleanup
(unless dape-test--skip-cleanup
(advice-add 'yes-or-no-p :around (defun always-yes (&rest _) t))
(dape-quit)
(setq dape--info-expanded-p
(make-hash-table :test 'equal))
(setq dape--watched nil)
(dape-test--should
(not dape--process) 10)
(not (dape--live-connection t)) 10)
(dape-test--should
(not (seq-find (lambda (buffer)
(string-match-p "\\*dape-.+\\*"
(buffer-name buffer)))
(and (not (equal (buffer-name buffer)
"*dape-connection events*"))
(string-match-p "\\*dape-.+\\*"
(buffer-name buffer))))
(buffer-list))))
(dape-test--should
(not (process-list)))
(not (process-list)) 10)
(advice-remove 'yes-or-no-p 'always-yes)
(dolist (buffer buffers)
(kill-buffer buffer))
Expand All @@ -116,9 +119,15 @@ Helper for `dape-test--with-files'."
(when (re-search-forward regex nil)
(funcall-interactively fn))))

(defun dape-test--stopped-p ()
"If current adapter connection is stopped."
(dape--stopped-threads (dape--live-connection t)))

(defun dape-test--debug (key &rest options)
"Invoke `dape' config KEY with OPTIONS."
(dape (dape--config-eval key options)))
(let ((config (dape--config-eval key options)))
(dape config)
(setq dape-history (list (dape--config-to-string key config)))))

;;; Tests
(defun dape--test-restart (buffer &rest dape-args)
Expand All @@ -133,15 +142,17 @@ Expects line with string \"breakpoint\" in source."
(apply 'dape-test--debug dape-args)
;; at breakpoint and stopped
(dape-test--should
(and (eq dape--state 'stopped)
(and (dape-test--stopped-p)
(equal (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))
(sleep-for 1) ;; FIXME Regression dape messes up current live connection
;; on fast restarts
;; restart
(goto-char (point-min))
(dape-restart)
;; at breakpoint and stopped
(dape-test--should
(and (eq dape--state 'stopped)
(and (dape-test--stopped-p)
(equal (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))))

Expand Down Expand Up @@ -201,15 +212,17 @@ Expects line with string \"breakpoint\" in source."
(apply 'dape-test--debug dape-args)
;; at breakpoint and stopped
(dape-test--should
(and (eq dape--state 'stopped)
(and (dape-test--stopped-p)
(equal (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))
(sleep-for 1) ;; FIXME Regression dape messes up current live connection
;; on fast restarts
;; restart
(goto-char (point-min))
(apply 'dape-test--debug dape-args)
;; at breakpoint and stopped
(dape-test--should
(and (eq dape--state 'stopped)
(and (dape-test--stopped-p)
(equal (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))))

Expand Down Expand Up @@ -288,8 +301,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--should
(not (dape-test--line-at-regex "^ member")))
;; set value
(when (eq (plist-get dape--capabilities :supportsSetVariable)
t)
(when (dape--capable-p (dape--live-connection t) :supportsSetVariable)
(dape-test--should
(dape-test--line-at-regex "^ a *0"))
(cl-letf (((symbol-function 'read-string)
Expand Down Expand Up @@ -373,7 +385,7 @@ Expects line with string \"breakpoint\" in source."
(equal (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))
(dape-test--should
(equal dape--state 'stopped))
(dape-test--stopped-p))
;; contents of watch buffer
(with-current-buffer (dape-test--should
(dape--info-get-live-buffer 'dape-info-watch-mode))
Expand Down Expand Up @@ -544,15 +556,15 @@ Expects line with string \"breakpoint\" in source."
:program (buffer-file-name main-buffer)
:cwd default-directory)
;; at breakpoint and stopped
(dape-test--should (dape--stopped-threads))
(dape-test--should (dape-test--stopped-p))
(with-current-buffer main-buffer
(dape-test--should
(= (line-number-at-pos)
(dape-test--line-at-regex "breakpoint"))))
(pop-to-buffer "*dape-repl*")
(insert "next")
(comint-send-input)
(dape-test--should (dape--stopped-threads))
(dape-test--should (dape-test--stopped-p))
(with-current-buffer main-buffer
(dape-test--should
(= (line-number-at-pos)
Expand All @@ -563,7 +575,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--should
(and (= (line-number-at-pos)
(dape-test--line-at-regex "third line"))
(eq dape--state 'stopped))))
(dape-test--stopped-p))))
(insert "a = 99")
(comint-send-input)
(with-current-buffer (dape-test--should
Expand All @@ -589,7 +601,7 @@ Expects line with string \"breakpoint\" in source."
:cwd default-directory)
;; at breakpoint and stopped
(dape-test--should
(eq dape--state 'stopped))
(dape-test--stopped-p))
(dape--info-buffer 'dape-info-modules-mode)
;; contents
(with-current-buffer (dape-test--should
Expand All @@ -615,8 +627,7 @@ Expects line with string \"breakpoint\" in source."
:program (buffer-file-name index-buffer)
:cwd default-directory)
;; stopped
(dape-test--should
(eq dape--state 'stopped))
(dape-test--should (dape-test--stopped-p))
(dape--info-buffer 'dape-info-sources-mode)
;; contents
(with-current-buffer (dape-test--should
Expand Down
Loading
Loading