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 | ||
c5b0993e EW |
28 | \f |
29 | ;; Warning predicate | |
30 | (defun flymake-tests--current-face (file predicate) | |
31 | (let ((buffer (find-file-noselect file))) | |
32 | (unwind-protect | |
33 | (with-current-buffer (find-file-noselect file) | |
34 | (setq-local flymake-warning-predicate predicate) | |
35 | (goto-char (point-min)) | |
36 | (flymake-mode 1) | |
37 | ;; XXX: is this reliable enough? | |
38 | (sleep-for (+ 0.5 flymake-no-changes-timeout)) | |
39 | (flymake-goto-next-error) | |
40 | (face-at-point)) | |
41 | (and buffer (kill-buffer buffer))))) | |
42 | ||
adc5dbce | 43 | (ert-deftest warning-predicate-rx-gcc () |
c5b0993e EW |
44 | "Test GCC warning via regexp predicate." |
45 | :expected-result (if (executable-find "gcc") :passed :failed) | |
46 | (should (eq 'flymake-warnline | |
47 | (flymake-tests--current-face | |
48 | "flymake/warnpred/test.c" | |
49 | "^[Ww]arning")))) | |
50 | ||
51 | (ert-deftest warning-predicate-function-gcc () | |
52 | "Test GCC warning via function predicate." | |
53 | :expected-result (if (and (executable-find "gcc") (executable-find "make")) | |
54 | :passed | |
55 | :failed) | |
56 | (should (eq 'flymake-warnline | |
57 | (flymake-tests--current-face | |
58 | "flymake/warnpred/test.c" | |
59 | (lambda (msg) (string-match "^[Ww]arning" msg)))))) | |
60 | ||
61 | (ert-deftest warning-predicate-rx-perl () | |
62 | "Test perl warning via regular expression predicate." | |
63 | :expected-result (if (executable-find "perl") :passed :failed) | |
64 | (should (eq 'flymake-warnline | |
65 | (flymake-tests--current-face | |
66 | "flymake/warnpred/test.pl" | |
67 | "^Scalar value")))) | |
68 | ||
69 | (ert-deftest warning-predicate-function-perl () | |
70 | "Test perl warning via function predicate." | |
71 | :expected-result (if (executable-find "perl") :passed :failed) | |
72 | (should (eq 'flymake-warnline | |
73 | (flymake-tests--current-face | |
74 | "flymake/warnpred/test.pl" | |
75 | (lambda (msg) (string-match "^Scalar value" msg)))))) | |
76 | ||
77 | (provide 'flymake-tests) | |
78 | ||
79 | ;;; flymake.el ends here |