Skip to content

Commit 63ef56b

Browse files
committed
Stabilize lsp-sonarlint-display-rule-descr-test
1 parent 043bda7 commit 63ef56b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/lsp-sonarlint-integration-test.el

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
;; You should have received a copy of the GNU General Public License
1919
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
;; Package-Requires: ((emacs "27.2"))
2021

2122
;;; Commentary:
2223
;; Tests for the integration of the LSP mode and SonarLint language server
@@ -180,7 +181,7 @@ If nil, use python-mode by default."
180181
'("cpp:S995"))))
181182

182183
(defun lsp-sonarlint--find-descr-action-at-point ()
183-
"Find the 'get rule description' code action for the issue at point."
184+
"Find the `get rule description' code action for the issue at point."
184185
(seq-find (lambda (action) (string-match-p "description" (gethash "title" action)))
185186
(lsp-code-actions-at-point)))
186187

@@ -213,19 +214,22 @@ If nil, use python-mode by default."
213214
(lsp-sonarlint--go-to-first-diag diags)
214215
(let ((descr-action (lsp-sonarlint--find-descr-action-at-point)))
215216
(let ((description-opened nil))
216-
(cl-flet ((check-opened-buffer
217-
(buf)
218-
(when (lsp-sonarlint--buf-has-rule-descr-p buf)
219-
(setq description-opened t))))
217+
(cl-flet ((check-opened-buffer (buf)
218+
(when (lsp-sonarlint--buf-has-rule-descr-p buf)
219+
(setq description-opened t))))
220220
(unwind-protect
221221
(progn
222222
(advice-add 'shr-render-buffer :before #'check-opened-buffer)
223-
(sit-for 1)
224-
(lsp-execute-code-action descr-action)
225223
(with-timeout (8 (error "Timeout waiting for rule description"))
226224
(while (not description-opened)
225+
;; Repeat the request multiple times because SonarLint
226+
;; might get distracted with other requests and "forget" to
227+
;; respond
228+
(lsp-execute-code-action descr-action)
227229
(message "still waiting")
228-
(sit-for 0.1)))
230+
(sit-for 0.3)))
229231
(should description-opened))
230232
(advice-remove 'shr-render-buffer #'check-opened-buffer))))))
231233
'python-mode))
234+
235+
;;; integration.el ends here

0 commit comments

Comments
 (0)