Skip to content

Commit 117e32a

Browse files
committed
Necessary test fixes from other branches
1 parent 2ec3ffc commit 117e32a

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

fixtures/compile_commands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"directory": ".",
4-
"command": "/usr/bin/c++ sample.cpp",
4+
"command": "c++ sample.cpp",
55
"file": "sample.cpp",
66
"output": "dummy"
77
}

test/lsp-sonarlint-integration-test.el

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
(require 'lsp-mode)
2929
(require 'lsp-sonarlint)
30+
(load-file (expand-file-name "lsp-sonarlint-test-utils.el"
31+
(file-name-directory (or load-file-name (buffer-file-name)))))
3032

3133
(ert-deftest lsp-sonarlint-plugin-downloaded ()
3234
"Check whether you have downloaded SonarLint.
@@ -109,18 +111,6 @@ only works for specific textDocument/didOpen:languageId."
109111
"Extract the code of each of ISSUES."
110112
(sort (mapcar (lambda (issue) (gethash "code" issue)) issues) #'string-lessp))
111113

112-
113-
(defun lsp-sonarlint--fixtures-dir ()
114-
"Directory of the test fixtures for these tests."
115-
(concat
116-
(file-name-directory
117-
(directory-file-name (file-name-directory (symbol-file #'lsp-sonarlint--fixtures-dir))))
118-
"fixtures/"))
119-
120-
(defun lsp-sonarlint--sample-file (fname)
121-
"Get the full path of the sample file FNAME."
122-
(concat (lsp-sonarlint--fixtures-dir) fname))
123-
124114
(defun lsp-sonarlint--get-all-issue-codes (sample-filename &optional major-mode)
125115
"Get all SonarLint issue-codes for given SAMPLE-FILENAME.
126116
This functions takes some time to wait for the LSP mode to init
@@ -129,7 +119,7 @@ MAJOR-MODE specifies the major mode enabled to trigger the analysis.
129119
Some analyzers like cfamily require specific major-modes.
130120
If nil, use python-mode by default."
131121
(lsp-sonarlint--exec-with-diags
132-
(lsp-sonarlint--sample-file sample-filename)
122+
(lsp-sonarlint-sample-file sample-filename)
133123
(lambda (diags)
134124
(lsp-sonarlint--get-codes-of-issues diags))
135125
(if major-mode major-mode 'python-mode)))
@@ -217,7 +207,7 @@ If nil, use python-mode by default."
217207
(ert-deftest lsp-sonarlint-display-rule-descr-test ()
218208
"Check whether you can display rule description for a SonarLint issue."
219209
(lsp-sonarlint--exec-with-diags
220-
(lsp-sonarlint--sample-file "sample.py")
210+
(lsp-sonarlint-sample-file "sample.py")
221211
(lambda (diags)
222212
(lsp-sonarlint--go-to-first-diag diags)
223213
(let ((descr-action (lsp-sonarlint--find-descr-action-at-point)))

test/lsp-sonarlint-test-utils.el

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;;; integration.el --- Integration tests for Sonarlint LSP client -*- lexical-binding: t; -*-
2+
;;;
3+
;; Author: Arseniy Zaostrovnykh
4+
;; Created: 11 July 2023
5+
;; License: GPL-3.0-or-later
6+
;;
7+
;; This program is free software; you can redistribute it and/or modify
8+
;; it under the terms of the GNU General Public License as published by
9+
;; the Free Software Foundation, either version 3 of the License, or
10+
;; (at your option) any later version.
11+
12+
;; This program is distributed in the hope that it will be useful,
13+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
;; GNU General Public License for more details.
16+
17+
;; You should have received a copy of the GNU General Public License
18+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
;;; Commentary:
21+
;; Utility functions for the LSP SonarLint tests.
22+
23+
;;; Code:
24+
25+
(defun lsp-sonarlint-fixtures-dir ()
26+
"Directory of the test fixtures for these tests."
27+
(concat
28+
(file-name-directory
29+
(directory-file-name (file-name-directory (symbol-file #'lsp-sonarlint-fixtures-dir))))
30+
"fixtures/"))
31+
32+
(defun lsp-sonarlint-sample-file (fname)
33+
"Get the full path of the sample file FNAME."
34+
(concat (lsp-sonarlint-fixtures-dir) fname))
35+
36+
(provide 'lsp-sonarlint-test-utils)
37+
38+
;;; lsp-sonarlint-test-utils.el ends here

0 commit comments

Comments
 (0)