Commit | Line | Data |
---|---|---|
c5b0993e EW |
1 | ;;; flymake-tests.el --- Test suite for flymake |
2 | ||
3 | ;; Copyright (C) 2011-2013 Free Software Foundation, Inc. | |
4 | ||
5 | ;; Author: Eduard Wiebe <usenet@pusto.de> | |
6 | ||
7 | ;; This file is part of GNU Emacs. | |
8 | ||
9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | |
10 | ;; it under the terms of the GNU General Public License as published by | |
11 | ;; the Free Software Foundation, either version 3 of the License, or | |
12 | ;; (at your option) any later version. | |
13 | ||
14 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;; GNU General Public License for more details. | |
18 | ||
19 | ;; You should have received a copy of the GNU General Public License | |
20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
22 | ;;; Commentary: | |
23 | ||
24 | ;;; Code: | |
25 | (require 'ert) | |
26 | (require 'flymake) | |
27 | ||
28 | (defgroup flymake-tests nil | |
29 | "Test suite for flymake.") | |
30 | ||
31 | \f | |
32 | ;; Warning predicate | |
33 | (defun flymake-tests--current-face (file predicate) | |
34 | (let ((buffer (find-file-noselect file))) | |
35 | (unwind-protect | |
36 | (with-current-buffer (find-file-noselect file) | |
37 | (setq-local flymake-warning-predicate predicate) | |
38 | (goto-char (point-min)) | |
39 | (flymake-mode 1) | |
40 | ;; XXX: is this reliable enough? | |
41 | (sleep-for (+ 0.5 flymake-no-changes-timeout)) | |
42 | (flymake-goto-next-error) | |
43 | (face-at-point)) | |
44 | (and buffer (kill-buffer buffer))))) | |
45 | ||
adc5dbce | 46 | (ert-deftest warning-predicate-rx-gcc () |
c5b0993e EW |
47 | "Test GCC warning via regexp predicate." |
48 | :expected-result (if (executable-find "gcc") :passed :failed) | |
49 | (should (eq 'flymake-warnline | |
50 | (flymake-tests--current-face | |
51 | "flymake/warnpred/test.c" | |
52 | "^[Ww]arning")))) | |
53 | ||
54 | (ert-deftest warning-predicate-function-gcc () | |
55 | "Test GCC warning via function predicate." | |
56 | :expected-result (if (and (executable-find "gcc") (executable-find "make")) | |
57 | :passed | |
58 | :failed) | |
59 | (should (eq 'flymake-warnline | |
60 | (flymake-tests--current-face | |
61 | "flymake/warnpred/test.c" | |
62 | (lambda (msg) (string-match "^[Ww]arning" msg)))))) | |
63 | ||
64 | (ert-deftest warning-predicate-rx-perl () | |
65 | "Test perl warning via regular expression predicate." | |
66 | :expected-result (if (executable-find "perl") :passed :failed) | |
67 | (should (eq 'flymake-warnline | |
68 | (flymake-tests--current-face | |
69 | "flymake/warnpred/test.pl" | |
70 | "^Scalar value")))) | |
71 | ||
72 | (ert-deftest warning-predicate-function-perl () | |
73 | "Test perl warning via function predicate." | |
74 | :expected-result (if (executable-find "perl") :passed :failed) | |
75 | (should (eq 'flymake-warnline | |
76 | (flymake-tests--current-face | |
77 | "flymake/warnpred/test.pl" | |
78 | (lambda (msg) (string-match "^Scalar value" msg)))))) | |
79 | ||
80 | (provide 'flymake-tests) | |
81 | ||
82 | ;;; flymake.el ends here |