Skip to content

Commit f0d96bf

Browse files
committed
Add tests passed count
1 parent 66719bd commit f0d96bf

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lsp-dart-test-support.el

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ not become focused. Otherwise the buffer is displayed and focused."
5454

5555
(defvar lsp-dart-test--suites nil)
5656
(defvar lsp-dart-test--tests nil)
57+
(defvar lsp-dart-test--tests-count 0)
58+
(defvar lsp-dart-test--tests-passed 0)
5759

5860
(cl-defstruct lsp-dart-test-suite
5961
(status nil)
@@ -62,7 +64,8 @@ not become focused. Otherwise the buffer is displayed and focused."
6264
(cl-defstruct lsp-dart-test
6365
(id nil)
6466
(name nil)
65-
(start-time nil))
67+
(start-time nil)
68+
(group-ids nil))
6669

6770
(cl-defstruct lsp-dart-test-len
6871
(file-name nil)
@@ -205,14 +208,19 @@ NOTIFICATION is the event notification.")
205208

206209
(cl-defmethod lsp-dart-test--handle-notification ((_event (eql start)) _notification)
207210
"Handle start NOTIFICATION."
208-
(setq lsp-dart-test--tests nil))
211+
(setq lsp-dart-test--tests nil)
212+
(setq lsp-dart-test--tests-count 0)
213+
(setq lsp-dart-test--tests-passed 0))
209214

210215
(cl-defmethod lsp-dart-test--handle-notification ((_event (eql testStart)) notification)
211216
"Handle testStart NOTIFICATION."
212-
(-let (((&TestStartNotification :time :test (&Test :id :name?)) notification))
217+
(-let (((&TestStartNotification :time :test (&Test :id :group-i-ds :name?)) notification))
213218
(lsp-dart-test--set-test id (make-lsp-dart-test :id id
214219
:name name?
215-
:start-time time))))
220+
:start-time time
221+
:group-ids group-i-ds))
222+
(unless (seq-empty-p group-i-ds)
223+
(setq lsp-dart-test--tests-count (1+ lsp-dart-test--tests-count)))))
216224

217225
(cl-defmethod lsp-dart-test--handle-notification ((_event (eql allSuites)) _notification)
218226
"Handle allSuites NOTIFICATION.")
@@ -232,8 +240,10 @@ NOTIFICATION is the event notification.")
232240

233241
(cl-defmethod lsp-dart-test--handle-notification ((_event (eql testDone)) notification)
234242
"Handle test done NOTIFICATION."
235-
(-let (((&TestDoneNotification :test-id :time :hidden) notification))
243+
(-let (((&TestDoneNotification :test-id :result :time :hidden) notification))
236244
(unless hidden
245+
(when (string= result "success")
246+
(setq lsp-dart-test--tests-passed (1+ lsp-dart-test--tests-passed)))
237247
(-when-let* ((test (lsp-dart-test--get-test test-id))
238248
(time (propertize (format "(%s ms)"
239249
(- time (lsp-dart-test-start-time test)))
@@ -250,7 +260,8 @@ NOTIFICATION is the event notification.")
250260
(if success
251261
(lsp-dart-test--send-output (propertize (format "\n%s All ran tests passed %s" lsp-dart-test--passed-icon lsp-dart-test--passed-icon)
252262
'font-lock-face 'success))
253-
(lsp-dart-test--send-output "\nFinished running tests"))))
263+
(lsp-dart-test--send-output (propertize (format "\n%s/%s tests passed" lsp-dart-test--tests-passed lsp-dart-test--tests-count)
264+
'font-lock-face font-lock-warning-face)))))
254265

255266
(cl-defmethod lsp-dart-test--handle-notification ((_event (eql print)) notification)
256267
"Handle print NOTIFICATION."

0 commit comments

Comments
 (0)