summaryrefslogtreecommitdiff
path: root/clippy-flymake-test.el
blob: 6039824c9db7833ee2dc0a8f07bf469c813933b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;;; clippy-flymake-test.el   -*- lexical-binding: t; -*-

(require 'clippy-flymake)
(require 'ert)

(defun run-regexp ()
  (set-match-data nil)
  (search-forward-regexp (clippy-flymake--build-regexp) nil t)
  (list (match-string 1)
        (match-string 2)
        (match-string 3)))

(ert-deftest clippy-test-regexp ()
  "Tests regexp matches diagnostic information."
  (should (equal (with-temp-buffer
                   (insert-file-contents "./test/fixture.txt")
                   (run-regexp))
                 '("warning: unused variable: `user`" "src/database/foo.rs" "42")))
  (should (equal (with-temp-buffer
                   (insert-file-contents "./test/fixture.txt")
                   (run-regexp)
                   (run-regexp))
                 '("warning: using `clone` on type `Status` which implements the `Copy` trait" "src/foo.rs" "31")))
  (should (equal (with-temp-buffer
                   (insert-file-contents "./test/fixture.txt")
                   (run-regexp)
                   (run-regexp)
                   (run-regexp))
                 '("warning: unused variable: `user`" "src/foobar/user.rs" "42"))))