summaryrefslogtreecommitdiff
path: root/rust-mode-tests.el
diff options
context:
space:
mode:
authorNathan Moreau <nathan.moreau@m4x.org>2020-05-29 04:50:03 +0200
committerNathan Moreau <nathan.moreau@m4x.org>2020-06-03 11:55:12 +0200
commit15a077a61743f49076eb9a1c5c77a4279e01a736 (patch)
treebcfcda5e5c6dab8594759f8dcd2f9fce5a871467 /rust-mode-tests.el
parentbded6679d0659032851d033cdd206aae2a884ba4 (diff)
downloadrust-mode-15a077a61743f49076eb9a1c5c77a4279e01a736.tar.gz
rustc-colon-compilation-regexps: improve highlighting.
Diffstat (limited to 'rust-mode-tests.el')
-rw-r--r--rust-mode-tests.el60
1 files changed, 35 insertions, 25 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 363d73c..da874ec 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -3338,6 +3338,31 @@ impl Two<'a> {
(let ((default-directory test-dir))
(should (equal (expand-file-name (rust-buffer-project)) manifest-file))))))
+(defun rust-collect-matches (spec)
+ (let ((matches nil))
+ (goto-char (point-min))
+ (while (re-search-forward (car spec) nil t)
+ (push
+ (mapcar (lambda (r)
+ (let ((match-pos
+ (nth (cdr r) spec)))
+ (if (eq :type (car r))
+ (cond ((consp match-pos)
+ (compilation-face match-pos))
+ (t
+ (cdr (assoc match-pos '((1 . compilation-warning)
+ (0 . compilation-info)
+ (2 . compilation-error))))))
+ (match-string match-pos))))
+ ;; see compilation-error-regexp-alist
+ '((:file . 1)
+ (:line . 2)
+ (:column . 3)
+ (:type . 4)
+ (:mouse-highlight . 5)))
+ matches))
+ (nreverse matches)))
+
(ert-deftest compilation-regexp-dashes ()
(with-temp-buffer
;; should match
@@ -3345,34 +3370,19 @@ impl Two<'a> {
(insert "error[E1234]: found a -> b\n --> file2.rs:12:34\n\n")
(insert "warning found a -> b\n --> file3.rs:12:34\n\n")
(insert "note: `ZZZ` could also refer to the constant imported here -> b\n --> file4.rs:12:34\n\n")
+ (insert " ::: file5.rs:12:34\n\n")
;; should not match
(insert "werror found a -> b\n --> no_match.rs:12:34\n\n")
- (goto-char (point-min))
- (let ((matches nil))
- (while (re-search-forward (car rustc-compilation-regexps) nil t)
- (push
- (mapcar (lambda (r)
- (let ((match-pos
- (nth (cdr r) rustc-compilation-regexps)))
- (if (eq :type (car r))
- (compilation-face match-pos)
- (match-string match-pos))))
- ;; see compilation-error-regexp-alist
- '((:file . 1)
- (:line . 2)
- (:column . 3)
- (:type . 4)
- (:mouse-highlight . 5)))
- matches))
- (setq matches (reverse matches))
-
- (should (equal
- '(("file1.rs" "12" "34" compilation-error "file1.rs:12:34")
- ("file2.rs" "12" "34" compilation-error "file2.rs:12:34")
- ("file3.rs" "12" "34" compilation-warning "file3.rs:12:34")
- ("file4.rs" "12" "34" compilation-info "file4.rs:12:34"))
- matches)))))
+ (should (equal
+ '((("file1.rs" "12" "34" compilation-error "file1.rs:12:34")
+ ("file2.rs" "12" "34" compilation-error "file2.rs:12:34")
+ ("file3.rs" "12" "34" compilation-warning "file3.rs:12:34")
+ ("file4.rs" "12" "34" compilation-info "file4.rs:12:34"))
+ (("file5.rs" "12" "34" compilation-info "file5.rs:12:34")))
+ (mapcar #'rust-collect-matches
+ (list rustc-compilation-regexps
+ rustc-colon-compilation-regexps))))))
;; If electric-pair-mode is available, load it and run the tests that use it. If not,
;; no error--the tests will be skipped.