Skip to content

Commit

Permalink
A lot of stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
svaante committed Jan 2, 2024
1 parent 2f6ba5a commit 61c0616
Show file tree
Hide file tree
Showing 3 changed files with 865 additions and 773 deletions.
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
João Távora for jsonrpc and input.
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--connection) 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

0 comments on commit 61c0616

Please sign in to comment.