[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/idris-mode bb26a21566 6/6: Merge pull request #607 from ke
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/idris-mode bb26a21566 6/6: Merge pull request #607 from keram/impro-xref-integration |
Date: |
Wed, 11 Jan 2023 10:03:40 -0500 (EST) |
branch: elpa/idris-mode
commit bb26a215664473cb68906c3febe0e8a6ab346796
Merge: f5bf588ef3 c3e11a8117
Author: Jan de Muijnck-Hughes <jfdm@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #607 from keram/impro-xref-integration
Fix small bug in idris-xref jump to column and
---
idris-xref.el | 4 +-
test/idris-xref-test.el | 262 ++++++++++++++++++++++--------------------------
2 files changed, 121 insertions(+), 145 deletions(-)
diff --git a/idris-xref.el b/idris-xref.el
index bbc6cb88da..f8914116e7 100644
--- a/idris-xref.el
+++ b/idris-xref.el
@@ -93,8 +93,8 @@ update coordinates to be indexed from 1 as expected by Emacs."
candidate))
(let ((new-fn (idris-xref-filepath term fn)))
`(,term (:filename ,new-fn)
- (:start ,(1+ start-line) ,(1+ start-col))
- (:end ,(1+ end-line) ,(1+ end-col))))))
+ (:start ,(1+ start-line) ,start-col)
+ (:end ,(1+ end-line) ,end-col)))))
(defun idris-xref-make-xref (location)
"Return a new Xref object from LOCATION."
diff --git a/test/idris-xref-test.el b/test/idris-xref-test.el
index 57d62cb63e..7b8bcc4a88 100644
--- a/test/idris-xref-test.el
+++ b/test/idris-xref-test.el
@@ -21,24 +21,20 @@
(require 'ert)
(require 'idris-xref)
+(eval-when-compile (require 'cl-lib))
(ert-deftest idris-xref-backend-definitions--error-when-no-connection ()
"Test that the file is loaded before making search for definition."
(let ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (inhibit-read-only t))
- (with-current-buffer "*Messages*" (erase-buffer))
+ error-msg)
(with-current-buffer buffer
(goto-char (point-min))
(search-forward ": Test")
(condition-case err
(funcall-interactively 'xref-find-definitions "Test")
- (error (message "Error: %s" (error-message-string err)))
- (user-error (message "User Error: %s" (error-message-string err)))))
+ (error (setq error-msg (error-message-string err)))))
- (with-current-buffer "*Messages*"
- (should
- (string-match-p "Buffer AddClause.idr has no process"
- (buffer-substring-no-properties (point-min)
(point-max)))))
+ (should (string-match-p "Buffer AddClause.idr has no process" error-msg))
;; Cleanup
(kill-buffer buffer)))
@@ -46,12 +42,12 @@
(ert-deftest idris-xref-backend-definitions--not-supported-on-Idris-1 ()
"Test that user error raised when invoking `xref-find-definitions' used on
Idris1."
(let ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (err-msg "did not understand (synchronous Idris evaluation failed)")
- (inhibit-read-only t))
- (with-current-buffer "*Messages*" (erase-buffer))
+ (stub-err-msg "did not understand (synchronous Idris evaluation
failed)")
+ error-msg)
+
(cl-flet ((idris-load-file-sync-stub () nil)
(idris-eval-stub (&optional &rest _args)
- (user-error err-msg)))
+ (user-error stub-err-msg)))
(advice-add 'idris-load-file-sync :override #'idris-load-file-sync-stub)
(advice-add 'idris-eval :override #'idris-eval-stub)
@@ -62,14 +58,12 @@
(condition-case err
(funcall-interactively 'xref-find-definitions "Test")
- (error (message "%s" (error-message-string err)))))
+ (error (setq error-msg (error-message-string err)))))
(advice-remove 'idris-load-file-sync #'idris-load-file-sync-stub)
(advice-remove 'idris-eval #'idris-eval-stub)))
- (with-current-buffer "*Messages*"
- (should
- (string-match-p err-msg (buffer-substring-no-properties (point-min)
(point-max)))))
+ (should (string-match-p stub-err-msg error-msg))
;; Cleanup
(kill-buffer buffer)))
@@ -79,8 +73,8 @@
;; Arrange
(let ((buffer (find-file-noselect "test-data/AddClause.idr"))
(idris-protocol-version 3)
- (inhibit-read-only t))
- (with-current-buffer "*Messages*" (erase-buffer))
+ error-msg)
+
(cl-flet ((idris-load-file-sync-stub () nil)
(idris-eval-stub (&optional &rest _args) '()))
(advice-add 'idris-load-file-sync :override #'idris-load-file-sync-stub)
@@ -90,21 +84,16 @@
(with-current-buffer buffer
(goto-char (point-min))
(search-forward ": Test")
- ;; (with-demoted-errors "Error: %s"
- ;; ;; Act
- ;; (funcall-interactively 'xref-find-definitions "Test"))
+
(condition-case err
(funcall-interactively 'xref-find-definitions "Test")
- (user-error (message "%s" (error-message-string err)))))
+ (user-error (setq error-msg (error-message-string err)))))
(advice-remove 'idris-load-file-sync #'idris-load-file-sync-stub)
(advice-remove 'idris-eval #'idris-eval-stub)))
- (with-current-buffer "*Messages*"
- ;; Assert
- (should
- (string-match-p "No definitions found for: Test"
- (buffer-substring-no-properties (point-min)
(point-max)))))
+ (should (string-match-p "No definitions found for: Test" error-msg))
+
;; Cleanup
(kill-buffer buffer)))
@@ -115,9 +104,8 @@
(eval-result `((("AddClause.Test"
(:filename ,(buffer-file-name buffer))
(:start 2 0)
- (:end 2 17)))))
- (inhibit-read-only t))
- (with-current-buffer "*Messages*" (erase-buffer))
+ (:end 2 17))))))
+
(cl-flet ((idris-load-file-sync-stub () nil)
(idris-eval-stub (&optional &rest _args) eval-result))
(advice-add 'idris-load-file-sync :override #'idris-load-file-sync-stub)
@@ -129,9 +117,7 @@
(search-forward ": Test")
(should (eq 6 (line-number-at-pos (point))))
- (condition-case err
- (funcall-interactively 'xref-find-definitions "Test")
- (user-error (message "%s" (error-message-string err))))
+ (funcall-interactively 'xref-find-definitions "Test")
(should (eq 3 (line-number-at-pos (point)))))
@@ -149,8 +135,8 @@
(:filename "(Interactive)")
(:start 0 0)
(:end 0 0)))))
- (inhibit-read-only t))
- (with-current-buffer "*Messages*" (erase-buffer))
+ error-msg)
+
(cl-flet ((idris-load-file-sync-stub () nil)
(idris-eval-stub (&optional &rest _args) eval-result))
(advice-add 'idris-load-file-sync :override #'idris-load-file-sync-stub)
@@ -160,21 +146,16 @@
(with-current-buffer buffer
(goto-char (point-min))
(search-forward ": Test")
- ;; (with-demoted-errors "Error: %s"
- ;; ;; Act
- ;; (funcall-interactively 'xref-find-definitions "Test"))
+
(condition-case err
(funcall-interactively 'xref-find-definitions "Test")
- (user-error (message "%s" (error-message-string err)))))
+ (user-error (setq error-msg (error-message-string err)))))
(advice-remove 'idris-load-file-sync #'idris-load-file-sync-stub)
(advice-remove 'idris-eval #'idris-eval-stub)))
- (with-current-buffer "*Messages*"
- ;; Assert
- (should
- (string-match-p "prim__lte_Bits64 : (Interactive)"
- (buffer-substring-no-properties (point-min)
(point-max)))))
+ (should (string-match-p "prim__lte_Bits64 : (Interactive)" error-msg))
+
;; Cleanup
(kill-buffer buffer)))
@@ -203,12 +184,8 @@
(with-current-buffer buffer
(goto-char (point-min))
(search-forward ": Test")
- ;; (with-demoted-errors "Error: %s"
- ;; ;; Act
- ;; (funcall-interactively 'xref-find-definitions "Test"))
- (condition-case err
- (funcall-interactively 'xref-find-definitions "Test")
- (user-error (message "%s" (error-message-string err)))))
+
+ (funcall-interactively 'xref-find-definitions "Test"))
(advice-remove 'idris-load-file-sync #'idris-load-file-sync-stub)
(advice-remove 'idris-eval #'idris-eval-stub)))
@@ -230,99 +207,98 @@
The updated candidate should have absolute path to file when possible
and coordinates indexed as expected by Emacs."
(let* ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (candidate `("AddClause.Test"
- (:filename ,(buffer-file-name buffer))
- (:start 2 0)
- (:end 2 17)))
- (result (idris-xref-normalise candidate)))
-
- (pcase-let ((`(,_term (:filename ,fn)
- (:start ,start-line ,start-col)
- (:end ,_end-line ,_end-col))
- result))
- (should (string= fn (buffer-file-name buffer)))
- (should (eq start-line 3))
- (should (eq start-col 1))))
-
- ;; Test that the filepath is reconstructed from term
- ;; and Idris process current working directory
- (let* ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (candidate `("AddClause.Test"
- (:filename "(File-Not-Found)")
- (:start 2 0)
- (:end 2 17)))
- (idris-process-current-working-directory (file-name-directory
(buffer-file-name buffer)))
- (result (idris-xref-normalise candidate)))
-
- (pcase-let ((`(,_term (:filename ,fn)
- (:start ,start-line ,start-col)
- (:end ,_end-line ,_end-col))
- result))
- (should (string= fn (buffer-file-name buffer)))
- (should (eq start-line 3))
- (should (eq start-col 1))))
-
- ;; Test that the original filename returned if no success to
- ;; reconstruct real absolute file path
- (let* ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (candidate `("AddClause.Test"
- (:filename "(File-Not-Found)")
- (:start 2 0)
- (:end 2 17)))
- (idris-process-current-working-directory nil)
- (result (idris-xref-normalise candidate)))
-
- (pcase-let ((`(,_term (:filename ,fn)
- (:start ,start-line ,start-col)
- (:end ,_end-line ,_end-col))
- result))
- (should (string= fn "(File-Not-Found)"))
- (should (eq start-line 3))
- (should (eq start-col 1))))
-
- ;; Test that the filepath is reconstructed from term
- ;; and (idris-xref-idris-source-directories)
- (let* ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (candidate `("AddClause.Test"
- (:filename "(File-Not-Found)")
- (:start 2 0)
- (:end 2 17)))
- (idris-process-current-working-directory nil))
- (cl-flet ((idris-xref-idris-source-directories-stub
- ()
- (cons (file-name-directory (buffer-file-name buffer)) '())))
- (advice-add 'idris-xref-idris-source-directories
- :override #'idris-xref-idris-source-directories-stub)
-
- (let ((result (idris-xref-normalise candidate)))
- (pcase-let ((`(,_term (:filename ,fn)
- (:start ,start-line ,start-col)
- (:end ,_end-line ,_end-col))
- result))
-
- (should (string= fn (buffer-file-name buffer)))
- (should (eq start-line 3))
- (should (eq start-col 1))))
- (advice-remove 'idris-xref-idris-source-directories
- #'idris-xref-idris-source-directories-stub)))
-
- ;; Test that the filepath is reconstructed from term
- ;; and path from idris-xref-idris-source-locations
- (let* ((buffer (find-file-noselect "test-data/AddClause.idr"))
- (candidate `("AddClause.Test"
- (:filename "(File-Not-Found)")
- (:start 2 0)
- (:end 2 17)))
- (idris-xref-idris-source-locations (cons (file-name-directory
(buffer-file-name buffer)) '()))
- (result (idris-xref-normalise candidate)))
-
- (pcase-let ((`(,_term (:filename ,fn)
- (:start ,start-line ,start-col)
- (:end ,_end-line ,_end-col))
- result))
- (should (string= fn (buffer-file-name buffer)))
- (should (eq start-line 3))
- (should (eq start-col 1)))))
+ (abs-buffer-file-path (buffer-file-name buffer)))
+ (kill-buffer buffer)
+
+ (let* ((candidate `("AddClause.Test"
+ (:filename ,abs-buffer-file-path)
+ (:start 2 0)
+ (:end 2 17)))
+ (result (idris-xref-normalise candidate)))
+
+ (pcase-let ((`(,_term (:filename ,fn)
+ (:start ,start-line ,start-col)
+ (:end ,_end-line ,_end-col))
+ result))
+ (should (string= fn abs-buffer-file-path))
+ (should (eq start-line 3))
+ (should (eq start-col 0))))
+
+ ;; Test that the filepath is reconstructed from term
+ ;; and Idris process current working directory
+ (let* ((candidate `("AddClause.Test"
+ (:filename "(File-Not-Found)")
+ (:start 2 0)
+ (:end 2 17)))
+ (idris-process-current-working-directory (file-name-directory
abs-buffer-file-path))
+ (result (idris-xref-normalise candidate)))
+
+ (pcase-let ((`(,_term (:filename ,fn)
+ (:start ,start-line ,start-col)
+ (:end ,_end-line ,_end-col))
+ result))
+ (should (string= fn abs-buffer-file-path))
+ (should (eq start-line 3))
+ (should (eq start-col 0))))
+
+ ;; Test that the original filename returned if no success to
+ ;; reconstruct real absolute file path
+ (let* ((candidate `("AddClause.Test"
+ (:filename "(File-Not-Found)")
+ (:start 2 0)
+ (:end 2 17)))
+ (idris-process-current-working-directory nil)
+ (result (idris-xref-normalise candidate)))
+
+ (pcase-let ((`(,_term (:filename ,fn)
+ (:start ,start-line ,start-col)
+ (:end ,_end-line ,_end-col))
+ result))
+ (should (string= fn "(File-Not-Found)"))
+ (should (eq start-line 3))
+ (should (eq start-col 0))))
+
+ ;; Test that the filepath is reconstructed from term
+ ;; and (idris-xref-idris-source-directories)
+ (let* ((candidate `("AddClause.Test"
+ (:filename "(File-Not-Found)")
+ (:start 2 0)
+ (:end 2 17)))
+ (idris-process-current-working-directory nil))
+ (cl-flet ((idris-xref-idris-source-directories-stub
+ ()
+ (cons (file-name-directory abs-buffer-file-path) '())))
+ (advice-add 'idris-xref-idris-source-directories
+ :override #'idris-xref-idris-source-directories-stub)
+
+ (let ((result (idris-xref-normalise candidate)))
+ (pcase-let ((`(,_term (:filename ,fn)
+ (:start ,start-line ,start-col)
+ (:end ,_end-line ,_end-col))
+ result))
+
+ (should (string= fn abs-buffer-file-path))
+ (should (eq start-line 3))
+ (should (eq start-col 0))))
+ (advice-remove 'idris-xref-idris-source-directories
+ #'idris-xref-idris-source-directories-stub)))
+
+ ;; Test that the filepath is reconstructed from term
+ ;; and path from idris-xref-idris-source-locations
+ (let* ((candidate `("AddClause.Test"
+ (:filename "(File-Not-Found)")
+ (:start 2 0)
+ (:end 2 17)))
+ (idris-xref-idris-source-locations (cons (file-name-directory
abs-buffer-file-path) '()))
+ (result (idris-xref-normalise candidate)))
+
+ (pcase-let ((`(,_term (:filename ,fn)
+ (:start ,start-line ,start-col)
+ (:end ,_end-line ,_end-col))
+ result))
+ (should (string= fn abs-buffer-file-path))
+ (should (eq start-line 3))
+ (should (eq start-col 0))))))
(provide 'idris-xref-test)
;;; idris-xref-test.el ends here
- [nongnu] elpa/idris-mode updated (f69b32d689 -> bb26a21566), ELPA Syncer, 2023/01/11
- [nongnu] elpa/idris-mode bb26a21566 6/6: Merge pull request #607 from keram/impro-xref-integration,
ELPA Syncer <=
- [nongnu] elpa/idris-mode eb4b1fb530 2/6: Add extra iterations for processing in tests and, ELPA Syncer, 2023/01/11
- [nongnu] elpa/idris-mode 19aa3d7b02 3/6: Rewrite test idris-test-idris-type-at-point to use stubs, ELPA Syncer, 2023/01/11
- [nongnu] elpa/idris-mode f2cd31d1c5 1/6: Move test files to test/ directory, ELPA Syncer, 2023/01/11
- [nongnu] elpa/idris-mode f5bf588ef3 5/6: Merge pull request #606 from keram/test-restruct-draft, ELPA Syncer, 2023/01/11
- [nongnu] elpa/idris-mode c3e11a8117 4/6: Fix small bug in idris-xref jump to column and, ELPA Syncer, 2023/01/11