Skip to content

Commit 4b6749f

Browse files
committed
Add debug test at point
1 parent 4b1aacd commit 4b6749f

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LINT="(progn \
1818
build:
1919
cask install
2020

21-
test: build compile checkdoc lint
21+
test: clean build compile checkdoc lint
2222

2323
compile:
2424
@echo "Compiling..."
@@ -57,7 +57,7 @@ lint:
5757
*.el
5858

5959
clean:
60-
rm -rf .cask
60+
rm -rf .cask *.elc
6161

6262
tag:
6363
$(eval TAG := $(filter-out $@,$(MAKECMDGOALS)))

lsp-dart-test-support.el

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ PARAMS is the notification data from outline."
217217
"Return non-nil if FILE-NAME is a dart test files."
218218
(string-match "_test.dart" file-name))
219219

220+
(defun lsp-dart-test-support-test-overlay-at-point ()
221+
"Return test overlay at point.
222+
Return the overlay which has the smallest range of all test overlays in
223+
the current buffer."
224+
(-some--> (overlays-in (point-min) (point-max))
225+
(--filter (when (overlay-get it 'lsp-dart-test-code-lens)
226+
(-let* (((beg . end) (overlay-get it 'lsp-dart-test-overlay-test-range)))
227+
(and (>= (point) beg)
228+
(<= (point) end)))) it)
229+
(--min-by (-let* (((beg1 . end1) (overlay-get it 'lsp-dart-test-overlay-test-range))
230+
((beg2 . end2) (overlay-get other 'lsp-dart-test-overlay-test-range)))
231+
(and (< beg1 beg2)
232+
(> end1 end2))) it)))
233+
220234
(defun lsp-dart-test-support-run-last-test ()
221235
"Run last ran test."
222236
(if-let ((test (lsp-workspace-get-metadata "last-ran-test")))

lsp-dart.el

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,21 @@ If the version number could not be determined, signal an error."
408408

409409
;;;###autoload
410410
(defun lsp-dart-run-test-at-point ()
411-
"Run test checking for the previous overlay at point.
412-
Run test of the overlay which has the smallest range of
413-
all test overlays in the current buffer."
411+
"Run test at point.
412+
Search for the last test overlay."
414413
(interactive)
415-
(-some--> (overlays-in (point-min) (point-max))
416-
(--filter (when (overlay-get it 'lsp-dart-test-code-lens)
417-
(-let* (((beg . end) (overlay-get it 'lsp-dart-test-overlay-test-range)))
418-
(and (>= (point) beg)
419-
(<= (point) end)))) it)
420-
(--min-by (-let* (((beg1 . end1) (overlay-get it 'lsp-dart-test-overlay-test-range))
421-
((beg2 . end2) (overlay-get other 'lsp-dart-test-overlay-test-range)))
422-
(and (< beg1 beg2)
423-
(> end1 end2))) it)
424-
(lsp-dart-test-support-run (overlay-get it 'lsp-dart-test))))
414+
(if-let (overlay (lsp-dart-test-support-test-overlay-at-point))
415+
(lsp-dart-test-support-run (overlay-get overlay 'lsp-dart-test))
416+
(lsp-dart-project-log "No test found at point.")))
417+
418+
;;;###autoload
419+
(defun lsp-dart-debug-test-at-point ()
420+
"Debug test at point.
421+
Search for the last test overlay."
422+
(interactive)
423+
(if-let (overlay (lsp-dart-test-support-test-overlay-at-point))
424+
(lsp-dart-test-support-debug (overlay-get overlay 'lsp-dart-test))
425+
(lsp-dart-project-log "No test found at point.")))
425426

426427
;;;###autoload
427428
(defun lsp-dart-run-test-file ()

0 commit comments

Comments
 (0)