diff options
| author | Eduard Wiebe | 2013-06-21 10:36:13 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-06-21 10:36:13 -0400 |
| commit | c5b0993e5f54a664d7edbdf9caffb43555618c51 (patch) | |
| tree | ecf4f7c6ac5af5b19a3bb86a166ce0d30fbd0551 /test | |
| parent | a7d2d4654e2dd1075df0c45c15cae52924a44ada (diff) | |
| download | emacs-c5b0993e5f54a664d7edbdf9caffb43555618c51.tar.gz emacs-c5b0993e5f54a664d7edbdf9caffb43555618c51.zip | |
Extend flymake's warning predicate to be a function. Test suite for flymake.
* lisp/progmodes/flymake.el (flymake-warning-predicate): New.
(flymake-parse-line): Use it.
(flymake-warning-re): Make obsolete alias to
`flymake-warning-predicate'.
* doc/misc/flymake.texi (Parsing the output, Customizable variables):
Add reference to `flymake-warning-predicate'.
* test/automated/flymake-tests.el:
* test/automated/flymake/warnpred/Makefile
* test/automated/flymake/warnpred/test.c
* test/automated/flymake/warnpred/test.pl: New files.
Fixes: debbugs:14217
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 8 | ||||
| -rw-r--r-- | test/automated/flymake-tests.el | 82 | ||||
| -rw-r--r-- | test/automated/flymake/warnpred/Makefile | 8 | ||||
| -rw-r--r-- | test/automated/flymake/warnpred/test.c | 5 | ||||
| -rw-r--r-- | test/automated/flymake/warnpred/test.pl | 2 |
5 files changed, 105 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 90ea593a012..73ce74a02ae 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-06-21 Eduard Wiebe <usenet@pusto.de> | ||
| 2 | |||
| 3 | Test suite for flymake. | ||
| 4 | * automated/flymake-tests.el: | ||
| 5 | * automated/flymake/warnpred/Makefile | ||
| 6 | * automated/flymake/warnpred/test.c | ||
| 7 | * automated/flymake/warnpred/test.pl: New files. | ||
| 8 | |||
| 1 | 2013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | 9 | 2013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> |
| 2 | 10 | ||
| 3 | * automated/reftex-tests.el (reftex-parse-from-file-test): Fix test. | 11 | * automated/reftex-tests.el (reftex-parse-from-file-test): Fix test. |
diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el new file mode 100644 index 00000000000..6b68a956db8 --- /dev/null +++ b/test/automated/flymake-tests.el | |||
| @@ -0,0 +1,82 @@ | |||
| 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 | |||
| 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 | |||
| 46 | (ert-deftest warnining-predicate-rx-gcc () | ||
| 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 | ||
diff --git a/test/automated/flymake/warnpred/Makefile b/test/automated/flymake/warnpred/Makefile new file mode 100644 index 00000000000..33af51c3337 --- /dev/null +++ b/test/automated/flymake/warnpred/Makefile | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | # Makefile for flymake tests | ||
| 2 | |||
| 3 | CC_OPTS = -Wall | ||
| 4 | |||
| 5 | check-syntax: | ||
| 6 | $(CC) $(CC_OPTS) ${CHK_SOURCES} | ||
| 7 | |||
| 8 | # eof | ||
diff --git a/test/automated/flymake/warnpred/test.c b/test/automated/flymake/warnpred/test.c new file mode 100644 index 00000000000..3a3926131f5 --- /dev/null +++ b/test/automated/flymake/warnpred/test.c | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | int main() | ||
| 2 | { | ||
| 3 | char c = 1000; | ||
| 4 | return c; | ||
| 5 | } | ||
diff --git a/test/automated/flymake/warnpred/test.pl b/test/automated/flymake/warnpred/test.pl new file mode 100644 index 00000000000..2013b2e4434 --- /dev/null +++ b/test/automated/flymake/warnpred/test.pl | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | @arr = [1,2,3,4]; | ||
| 2 | @arr[1] = -1; | ||