-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure compilation DB path by request from SonarLint server
Try to find it automatically in one of the parent directories, ask user for it, otherwise.
- Loading branch information
Showing
15 changed files
with
147 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int x; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int x; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
;;; lsp-sonarlint-cpp-test.el --- CFamily analyzer-specific tests for Sonarlint LSP client -*- lexical-binding: t; -*- | ||
;;; | ||
;; Author: Arseniy Zaostrovnykh | ||
;; Created: 11 July 2023 | ||
;; License: GPL-3.0-or-later | ||
;; | ||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
;; Tests for the C++-specific integration of the LSP mode and SonarLint language server. | ||
|
||
;;; Code: | ||
|
||
(require 'lsp-mode) | ||
(require 'lsp-sonarlint) | ||
(load-file (expand-file-name "lsp-sonarlint-test-utils.el" | ||
(file-name-directory (or load-file-name (buffer-file-name))))) | ||
|
||
(defun lsp-sonarlint--get-compdb-for-sample-file (cpp-file) | ||
"Relative to fixtures folder, get compile_commands.json for CPP-FILE." | ||
(let ((buf (find-file-noselect (lsp-sonarlint-sample-file cpp-file)))) | ||
(with-current-buffer buf | ||
(file-relative-name (lsp-sonarlint--get-compile-commands) | ||
(lsp-sonarlint-fixtures-dir))))) | ||
|
||
(ert-deftest lsp-sonarlint--get-compile-commands-test () | ||
(should (equal (lsp-sonarlint--get-compdb-for-sample-file "compdb/dir1/1.cpp") | ||
"compdb/dir1/compile_commands.json")) | ||
(should (equal (lsp-sonarlint--get-compdb-for-sample-file "compdb/dir1/dir11/11.cpp") | ||
"compdb/dir1/dir11/compile_commands.json")) | ||
(should (equal (lsp-sonarlint--get-compdb-for-sample-file "compdb/dir1/dir12/12.cpp") | ||
"compdb/dir1/compile_commands.json")) | ||
(should (equal (lsp-sonarlint--get-compdb-for-sample-file "compdb/dir1/dir12/dir121/121.cpp") | ||
"compdb/dir1/compile_commands.json"))) | ||
|
||
(ert-deftest lsp-sonarlint--get-compile-commands-interactive-test () | ||
(cl-letf (((symbol-function 'read-file-name) (lambda (_prompt) | ||
(concat (lsp-sonarlint-fixtures-dir) "my_db.json")))) | ||
(should (equal (lsp-sonarlint--get-compdb-for-sample-file "compdb/no-compdb/no-compdb.cpp") | ||
"my_db.json")))) | ||
|
||
;;; lsp-sonarlint-cpp-test.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
;;; integration.el --- Integration tests for Sonarlint LSP client -*- lexical-binding: t; -*- | ||
;;; | ||
;; Author: Arseniy Zaostrovnykh | ||
;; Created: 11 July 2023 | ||
;; License: GPL-3.0-or-later | ||
;; | ||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
;; Utility functions for the LSP SonarLint tests. | ||
|
||
;;; Code: | ||
|
||
(defun lsp-sonarlint-fixtures-dir () | ||
"Directory of the test fixtures for these tests." | ||
(concat | ||
(file-name-directory | ||
(directory-file-name (file-name-directory (symbol-file #'lsp-sonarlint-fixtures-dir)))) | ||
"fixtures/")) | ||
|
||
(defun lsp-sonarlint-sample-file (fname) | ||
"Get the full path of the sample file FNAME." | ||
(concat (lsp-sonarlint-fixtures-dir) fname)) | ||
|
||
(provide 'lsp-sonarlint-test-utils) | ||
|
||
;;; lsp-sonarlint-test-utils.el ends here |