From 3db9f93c83052d6a8976c92d67d2b24473930760 Mon Sep 17 00:00:00 2001 From: Eric Dallo Date: Mon, 26 Dec 2022 15:29:12 -0300 Subject: [PATCH] Improve test output to be more precise on output messages. --- CHANGELOG.md | 1 + lsp-dart-test-output.el | 15 ++++++++------- lsp-dart-test-tree.el | 12 ++++++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5beb7d2..e18dca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lsp-dart-test-output.el b/lsp-dart-test-output.el index d5a63ed..baec002 100644 --- a/lsp-dart-test-output.el +++ b/lsp-dart-test-output.el @@ -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 @@ -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*") @@ -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)) @@ -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) diff --git a/lsp-dart-test-tree.el b/lsp-dart-test-tree.el index a36490b..626953b 100644 --- a/lsp-dart-test-tree.el +++ b/lsp-dart-test-tree.el @@ -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." @@ -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