[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape 32b66a2779 6/6: Use relative filenames in dape-con
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape 32b66a2779 6/6: Use relative filenames in dape-config |
Date: |
Sat, 13 Jan 2024 16:04:12 -0500 (EST) |
branch: externals/dape
commit 32b66a277902229dca5a5c9ddab898e7e8e85268
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <svaante@gmail.com>
Use relative filenames in dape-config
Improved readability
---
dape-tests.el | 149 ++++++++++++++++++++--------------------------------------
dape.el | 50 ++++++++++++--------
2 files changed, 82 insertions(+), 117 deletions(-)
diff --git a/dape-tests.el b/dape-tests.el
index 0d9d938ec7..d4f08c4adb 100644
--- a/dape-tests.el
+++ b/dape-tests.el
@@ -128,14 +128,17 @@ Helper for `dape-test--with-files'."
"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."
- (let ((config (dape--config-eval key options)))
- (dape config)
- (setq dape-history (list (dape--config-to-string key config)))))
+(defun dape-test--debug (buffer key &rest args)
+ "Invoke `dape' interactivly with KEY and ARGS."
+ (cl-letf (((symbol-function 'read-from-minibuffer)
+ (lambda (&rest _)
+ (concat (format "%s " key)
+ (mapconcat (lambda (o) (format "%S" o)) args " ")))))
+ (with-current-buffer buffer
+ (call-interactively 'dape))))
;;; Tests
-(defun dape--test-restart (buffer &rest dape-args)
+(defun dape--test-restart (buffer key &rest args)
"Helper for ert test `dape-test-restart'.
Expects line with string \"breakpoint\" in source."
(with-current-buffer buffer
@@ -144,7 +147,7 @@ Expects line with string \"breakpoint\" in source."
(save-excursion
(dape-test--goto-line line)
(dape-breakpoint-toggle)))
- (apply 'dape-test--debug dape-args)
+ (apply 'dape-test--debug buffer key args)
;; at breakpoint and stopped
(dape-test--should
(and (dape-test--stopped-p)
@@ -164,46 +167,33 @@ Expects line with string \"breakpoint\" in source."
(ert-deftest dape-test-restart ()
"Restart with restart."
(dape-test--with-files
- ((main-buffer
- "main.py"
- ("pass"
- "pass # breakpoint")))
- (dape--test-restart main-buffer
- 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory))
+ ((main-buffer
+ "main.py"
+ ("pass"
+ "pass # breakpoint")))
+ (dape--test-restart main-buffer 'debugpy))
(dape-test--with-files
- ((index-buffer
- "index.js"
- ("()=>{};"
- "()=>{}; // breakpoint")))
- (dape--test-restart index-buffer
- 'js-debug-node
- :program (buffer-file-name index-buffer)
- :cwd default-directory))
+ ((index-buffer
+ "index.js"
+ ("()=>{};"
+ "()=>{}; // breakpoint")))
+ (dape--test-restart index-buffer 'js-debug-node))
(dape-test--with-files
- ((index-buffer
- "main.c"
- ("int main() {"
- " return 0; // breakpoint"
- "}")))
- (dape--test-restart index-buffer
- 'codelldb-cc
- :program
- (file-name-concat default-directory "./a.out")
- :cwd default-directory
- 'compile "gcc -g -o a.out main.c"))
+ ((index-buffer
+ "main.c"
+ ("int main() {"
+ " return 0; // breakpoint"
+ "}")))
+ (dape--test-restart index-buffer
+ 'codelldb-cc
+ 'compile "gcc -g -o a.out main.c"))
(dape-test--with-files
- ((main-buffer
- "main.rb"
- ("puts \"\""
- "puts \"\""
- "0 # breakpoint")))
- (dape--test-restart main-buffer
- 'rdbg
- 'command-cwd default-directory
- '-c (format "ruby \"%s\""
- (buffer-file-name main-buffer)))))
+ ((main-buffer
+ "main.rb"
+ ("puts \"\""
+ "puts \"\""
+ "0 # breakpoint")))
+ (dape--test-restart main-buffer 'rdbg)))
(defun dape--test-restart-with-dape (buffer &rest dape-args)
"Helper for ert test `dape-test-restart-with-dape'.
@@ -214,7 +204,7 @@ Expects line with string \"breakpoint\" in source."
(save-excursion
(dape-test--goto-line line)
(dape-breakpoint-toggle)))
- (apply 'dape-test--debug dape-args)
+ (apply 'dape-test--debug buffer dape-args)
;; at breakpoint and stopped
(dape-test--should
(and (dape-test--stopped-p)
@@ -224,7 +214,7 @@ Expects line with string \"breakpoint\" in source."
;; on fast restarts
;; restart
(goto-char (point-min))
- (apply 'dape-test--debug dape-args)
+ (apply 'dape-test--debug buffer dape-args)
;; at breakpoint and stopped
(dape-test--should
(and (dape-test--stopped-p)
@@ -238,30 +228,20 @@ Expects line with string \"breakpoint\" in source."
"main.py"
("pass"
"pass # breakpoint")))
- (dape--test-restart-with-dape main-buffer
- 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory))
+ (dape--test-restart-with-dape main-buffer 'debugpy))
(dape-test--with-files
((index-buffer
"index.js"
("()=>{};"
"()=>{}; // breakpoint")))
- (dape--test-restart-with-dape index-buffer
- 'js-debug-node
- :program (buffer-file-name index-buffer)
- :cwd default-directory))
+ (dape--test-restart-with-dape index-buffer 'js-debug-node))
(dape-test--with-files
((main-buffer
"main.c"
("int main() {"
" return 0; // breakpoint"
"}")))
- (dape--test-restart-with-dape main-buffer
- 'codelldb-cc
- :program
- (file-name-concat default-directory
"./a.out")
- :cwd default-directory
+ (dape--test-restart-with-dape main-buffer 'codelldb-cc
'compile "gcc -g -o a.out main.c"))
(dape-test--with-files
((main-buffer
@@ -269,10 +249,7 @@ Expects line with string \"breakpoint\" in source."
("puts \"\""
"puts \"\""
"0 # breakpoint")))
- (dape--test-restart-with-dape main-buffer
- 'rdbg
- 'command-cwd default-directory
- '-c (format "ruby \"%s\"" (buffer-file-name
main-buffer)))))
+ (dape--test-restart-with-dape main-buffer 'rdbg)))
(defun dape--test-scope-buffer (buffer &rest dape-args)
"Helper for ert test `dape-test-scope-buffer-contents'.
@@ -285,7 +262,7 @@ Expects line with string \"breakpoint\" in source."
(save-excursion
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
- (apply 'dape-test--debug dape-args)
+ (apply 'dape-test--debug buffer dape-args)
;; we are at breakpoint and stopped
(with-current-buffer buffer
(dape-test--should
@@ -331,20 +308,14 @@ Expects line with string \"breakpoint\" in source."
"a = 0"
"b = B()"
"pass # breakpoint")))
- (dape--test-scope-buffer main-buffer
- 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory))
+ (dape--test-scope-buffer main-buffer 'debugpy))
(dape-test--with-files
((index-buffer
"index.js"
("var a = 0;"
"var b = {'member': 0};"
"()=>{}; // breakpoint")))
- (dape--test-scope-buffer index-buffer
- 'js-debug-node
- :program (buffer-file-name index-buffer)
- :cwd default-directory))
+ (dape--test-scope-buffer index-buffer 'js-debug-node))
(dape-test--with-files
((main
"main.c"
@@ -354,11 +325,7 @@ Expects line with string \"breakpoint\" in source."
" return 0; // breakpoint"
"}")))
(ignore main)
- (dape--test-scope-buffer main
- 'codelldb-cc
- :program
- (file-name-concat default-directory "./a.out")
- :cwd default-directory
+ (dape--test-scope-buffer main 'codelldb-cc
'compile "gcc -g -o a.out main.c")))
(ert-deftest dape-test-watch-buffer()
@@ -381,9 +348,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory)
+ (dape-test--debug main-buffer 'debugpy)
;; at breakpoint and stopped
(with-current-buffer main-buffer
(dape-test--should
@@ -437,9 +402,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory)
+ (dape-test--debug main-buffer 'debugpy)
;; at breakpoint and stopped
(with-current-buffer main-buffer
(dape-test--should
@@ -492,9 +455,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory)
+ (dape-test--debug main-buffer 'debugpy)
;; at breakpoint and stopped
(with-current-buffer main-buffer
(dape-test--should
@@ -557,9 +518,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory)
+ (dape-test--debug main-buffer 'debugpy)
;; at breakpoint and stopped
(dape-test--should (dape-test--stopped-p))
(with-current-buffer main-buffer
@@ -601,9 +560,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'debugpy
- :program (buffer-file-name main-buffer)
- :cwd default-directory)
+ (dape-test--debug main-buffer 'debugpy)
;; at breakpoint and stopped
(dape-test--should
(dape-test--stopped-p))
@@ -611,8 +568,8 @@ Expects line with string \"breakpoint\" in source."
;; contents
(with-current-buffer (dape-test--should
(dape--info-get-live-buffer 'dape-info-modules-mode))
- (dape-test--should
- (dape-test--line-at-regex "^__main__ of main.py")))))
+ (dape-test--should ;; Regression .* symlinks are now handled differently
+ (dape-test--line-at-regex "^__main__ of .*main.py")))))
(ert-deftest dape-test-sources-buffer ()
"Sources buffer contents and commands."
@@ -628,9 +585,7 @@ Expects line with string \"breakpoint\" in source."
(dape-test--goto-line line)
(dape-breakpoint-toggle))))
;; start debugging
- (dape-test--debug 'js-debug-node
- :program (buffer-file-name index-buffer)
- :cwd default-directory)
+ (dape-test--debug index-buffer 'js-debug-node)
;; stopped
(dape-test--should (dape-test--stopped-p))
(dape--info-buffer 'dape-info-sources-mode)
diff --git a/dape.el b/dape.el
index 0c9fe6d590..22a19fe45a 100644
--- a/dape.el
+++ b/dape.el
@@ -70,6 +70,7 @@
(defcustom dape-configs
`(,@(let ((codelldb
`(ensure dape-ensure-command
+ command-cwd dape-command-cwd
command ,(file-name-concat dape-adapter-dir
"codelldb"
"extension"
@@ -79,28 +80,29 @@
fn dape-config-autoport
:type "lldb"
:request "launch"
- :cwd dape-cwd
- :program ,(defun dape--rust-program ()
- (let ((root (dape-cwd)))
- (file-name-concat root "target" "debug"
- (thread-first root
-
(directory-file-name)
- (file-name-split)
- (last)
- (car)))))
+ :cwd "."
:args [])))
`((codelldb-cc
modes (c-mode c-ts-mode c++-mode c++-ts-mode)
command-args ("--port" :autoport)
- ,@codelldb)
+ ,@codelldb
+ :program "a.out")
(codelldb-rust
modes (rust-mode rust-ts-mode)
command-args ("--port" :autoport
"--settings" "{\"sourceLanguages\":[\"rust\"]}")
- ,@codelldb)))
+ ,@codelldb
+ :program ,(defun dape--rust-program ()
+ (file-name-concat "target" "debug"
+ (thread-first (dape-cwd)
+ (directory-file-name)
+ (file-name-split)
+ (last)
+ (car)))))))
(cpptools
modes (c-mode c-ts-mode c++-mode c++-ts-mode)
ensure dape-ensure-command
+ command-cwd dape-command-cwd
command ,(file-name-concat dape-adapter-dir
"cpptools"
"extension"
@@ -109,7 +111,7 @@
"OpenDebugAD7")
:type "cppdbg"
:request "launch"
- :cwd dape-cwd
+ :cwd "."
:program "a.out"
:MIMode ,(seq-find 'executable-find '("lldb" "gdb")))
(debugpy
@@ -125,11 +127,10 @@
fn (dape-config-autoport dape-config-tramp)
command "python"
command-args ("-m" "debugpy.adapter" "--host" "0.0.0.0" "--port"
:autoport)
- command-cwd dape-command-cwd
port :autoport
:request "launch"
:type "executable"
- :cwd dape-cwd
+ :cwd dape-command-cwd
:program dape-buffer-default
:justMyCode nil
:console "integratedTerminal"
@@ -145,8 +146,8 @@
port :autoport
:request "launch"
:type "debug"
- :cwd dape-cwd
- :program dape-cwd)
+ :cwd "."
+ :program ".")
(flutter
ensure dape-ensure-command
modes (dart-mode)
@@ -154,7 +155,7 @@
command-args ("debug_adapter")
command-cwd dape-command-cwd
:type "dart"
- :cwd dape-cwd
+ :cwd "."
:program "lib/main.dart"
:toolArgs ["-d" "all"])
(godot
@@ -201,9 +202,10 @@
(lldb-vscode
modes (c-mode c-ts-mode c++-mode c++-ts-mode rust-mode rust-ts-mode)
ensure dape-ensure-command
+ command-cwd dape-command-cwd
command "lldb-vscode"
:type "lldb-vscode"
- :cwd dape-cwd
+ :cwd "."
:program "a.out")
(netcoredbg
modes (csharp-mode csharp-ts-mode)
@@ -212,7 +214,14 @@
command-args ["--interpreter=vscode"]
:request "launch"
:cwd dape-cwd
- :program ".dll"
+ :program ,(defun dape--netcoredbg-program ()
+ (let ((dlls
+ (file-expand-wildcards
+ (file-name-concat "bin" "Debug" "*" "*.dll"))))
+ (if dlls
+ (file-relative-name (car dlls))
+ ".dll"
+ (dape-cwd))))
:stopAtEntry nil)
(rdbg
modes (ruby-mode ruby-ts-mode)
@@ -280,7 +289,7 @@
`(:filePath
,(defun dape--jdtls-file-path ()
(or (resolve-main-class :filePath)
- (dape-buffer-default)))
+ (expand-file-name (dape-buffer-default))))
:mainClass
,(defun dape--jdtls-main-class ()
(or (resolve-main-class :mainClass) ""))
@@ -3487,6 +3496,7 @@ Buffer is specified by MODE and ID."
dape-command-cwd
dape-buffer-default
dape--rust-program
+ dape--netcoredbg-program
dape--rdbg-c
dape--jdtls-file-path
dape--jdtls-main-class
- [elpa] externals/dape updated (8632214a6b -> 32b66a2779), ELPA Syncer, 2024/01/13
- [elpa] externals/dape acc56cb89c 5/6: Prepare for more relative filenames, ELPA Syncer, 2024/01/13
- [elpa] externals/dape 32b66a2779 6/6: Use relative filenames in dape-config,
ELPA Syncer <=
- [elpa] externals/dape 9bfc07dd99 2/6: Remove newline in compilation filed message, ELPA Syncer, 2024/01/13
- [elpa] externals/dape 17971a49db 1/6: Convert mode line active to global minor mode, ELPA Syncer, 2024/01/13
- [elpa] externals/dape e8bea3793b 4/6: Add hints to minibuffer, ELPA Syncer, 2024/01/13
- [elpa] externals/dape 6f2043ec98 3/6: Reuse stderr buffer as to not fill the buffer list, ELPA Syncer, 2024/01/13