Skip to content

Commit

Permalink
Improve test output to be more precise on output messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdallo committed Dec 26, 2022
1 parent 3c8c257 commit 3db9f93
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Avoid outdated test tree after tests run.
* Improve test output to be more precise on output messages.

## 1.24.1

Expand Down
15 changes: 8 additions & 7 deletions lsp-dart-test-output.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ When set to `display-only' the buffer will be displayed, but it will
not become focused, otherwise the buffer is displayed and focused."
:group 'lsp-dart
:type '(choice (const :tag "Create the buffer, but don't display it" nil)
(const :tag "Create and display the buffer, but don't focus it" display-only)
(const :tag "Create, display, and focus the buffer" t)))
(const :tag "Create and display the buffer, but don't focus it" display-only)
(const :tag "Create, display, and focus the buffer" t)))


;;; Internal
Expand All @@ -49,7 +49,7 @@ not become focused, otherwise the buffer is displayed and focused."

(defvar lsp-dart-test-output--tests-count 0)
(defvar lsp-dart-test-output--tests-passed 0)
(defvar lsp-dart-test-output--first-log t)
(defvar lsp-dart-test-output--show-loading-tests-message t)

(defconst lsp-dart-test-output--buffer-name "*LSP Dart tests*")

Expand Down Expand Up @@ -142,12 +142,13 @@ not become focused, otherwise the buffer is displayed and focused."

(defun lsp-dart-test-output--handle-run-started ()
"Handle test run started."
(setq lsp-dart-test-output--first-log t)
(setq lsp-dart-test-output--show-loading-tests-message t)
(lsp-dart-test-output--show-buffer)
(lsp-dart-test-output--send "Running tests...\n"))
(lsp-dart-test-output--send "Spawning test process..."))

(defun lsp-dart-test-output--handle-all-start (_notification)
"Handle all start notification."
(lsp-dart-test-output--send "Running tests...")
(setq lsp-dart-test-output--tests-count 0)
(setq lsp-dart-test-output--tests-passed 0))

Expand All @@ -157,11 +158,11 @@ not become focused, otherwise the buffer is displayed and focused."

(lsp-defun lsp-dart-test-output--handle-done ((notification &as &TestDoneNotification :result :time :hidden) test-name test-start-time)
"Handle test done notification."
(when lsp-dart-test-output--first-log
(when lsp-dart-test-output--show-loading-tests-message
(with-current-buffer (lsp-dart-test-output--get-buffer-create)
(let ((inhibit-read-only t))
(erase-buffer)))
(setq lsp-dart-test-output--first-log nil))
(setq lsp-dart-test-output--show-loading-tests-message nil))
(let ((text (propertize (concat (lsp-dart-test-output--get-icon notification)
" "
test-name)
Expand Down
12 changes: 10 additions & 2 deletions lsp-dart-test-tree.el
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ POSITION is the test start position."
(lsp-dart-test-tree-add-suite suite))

(lsp-defun lsp-dart-test-tree--handle-group ((&GroupNotification :group))
(lsp-dart-test-tree-set-group group))
(lsp-dart-test-tree-set-group group))

(lsp-defun lsp-dart-test-tree--handle-start ((&TestStartNotification :test))
"Handle test start notification."
Expand All @@ -332,9 +332,17 @@ POSITION is the test start position."
"Handle test done notification."
(lsp-dart-test-tree-mark-as-done test-id (- time test-start-time) result skipped))

(defun lsp-dart-test-tree--render-final (suite-or-group)
"Rebuild the test tree for SUITE-OR-GROUP one last time."
(seq-map
(-lambda ((_group-id . group))
(lsp-dart-test-tree--render-final group)
(lsp-dart-test-tree--render))
(plist-get suite-or-group :groups)))

(defun lsp-dart-test-tree--handle-all-done (_params)
"Handle test done notification."
(lsp-dart-test-tree--render))
(seq-map #'lsp-dart-test-tree--render-final (map-values lsp-dart-test-tree--suites)))


;;; Public
Expand Down

0 comments on commit 3db9f93

Please sign in to comment.