diff options
| author | João Távora | 2017-09-21 14:57:20 +0100 |
|---|---|---|
| committer | João Távora | 2017-10-03 13:52:24 +0100 |
| commit | 0d26e45ab47d781e561bb415e28aab8cb166ced2 (patch) | |
| tree | 5e080e212454eb35f7a6be226873ae2ba9d08f9f /test | |
| parent | 7787988587eacb9aa77bbfb830a885fab8edd828 (diff) | |
| download | emacs-0d26e45ab47d781e561bb415e28aab8cb166ced2.tar.gz emacs-0d26e45ab47d781e561bb415e28aab8cb166ced2.zip | |
Add a new Flymake test for multiple errors and warnings
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Save excursion.
(errors-and-warnings): New test.
* test/lisp/progmodes/flymake-resources/errors-and-warnings.c:
New test fixture.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/flymake-resources/errors-and-warnings.c | 10 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-tests.el | 48 |
2 files changed, 42 insertions, 16 deletions
diff --git a/test/lisp/progmodes/flymake-resources/errors-and-warnings.c b/test/lisp/progmodes/flymake-resources/errors-and-warnings.c new file mode 100644 index 00000000000..6454dd20236 --- /dev/null +++ b/test/lisp/progmodes/flymake-resources/errors-and-warnings.c | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | int main() | ||
| 2 | { | ||
| 3 | char c = 1000; | ||
| 4 | int bla; | ||
| 5 | /* The following line should have one warning and one error. The | ||
| 6 | warning spans the full line because gcc (at least 6.3.0) points | ||
| 7 | places the error at the =, which isn't a sexp.*/ | ||
| 8 | char c; if (bla == (void*)3); | ||
| 9 | return c; | ||
| 10 | } | ||
diff --git a/test/lisp/progmodes/flymake-tests.el b/test/lisp/progmodes/flymake-tests.el index c626aec04bd..5e76f3136ea 100644 --- a/test/lisp/progmodes/flymake-tests.el +++ b/test/lisp/progmodes/flymake-tests.el | |||
| @@ -49,23 +49,24 @@ SEVERITY-PREDICATE is used to setup | |||
| 49 | (i 0)) | 49 | (i 0)) |
| 50 | (unwind-protect | 50 | (unwind-protect |
| 51 | (with-current-buffer buffer | 51 | (with-current-buffer buffer |
| 52 | (when sev-pred-supplied-p | 52 | (save-excursion |
| 53 | (setq-local flymake-proc-warning-predicate severity-predicate)) | 53 | (when sev-pred-supplied-p |
| 54 | (goto-char (point-min)) | 54 | (setq-local flymake-proc-warning-predicate severity-predicate)) |
| 55 | (flymake-mode 1) | 55 | (goto-char (point-min)) |
| 56 | ;; Weirdness here... http://debbugs.gnu.org/17647#25 | 56 | (flymake-mode 1) |
| 57 | ;; ... meaning `sleep-for', and even | 57 | ;; Weirdness here... http://debbugs.gnu.org/17647#25 |
| 58 | ;; `accept-process-output', won't suffice as ways to get | 58 | ;; ... meaning `sleep-for', and even |
| 59 | ;; process filters and sentinels to run, though they do work | 59 | ;; `accept-process-output', won't suffice as ways to get |
| 60 | ;; fine in a non-interactive batch session. The only thing | 60 | ;; process filters and sentinels to run, though they do work |
| 61 | ;; that will indeed unblock pending process output is | 61 | ;; fine in a non-interactive batch session. The only thing |
| 62 | ;; reading an input event, so, as a workaround, use a dummy | 62 | ;; that will indeed unblock pending process output is |
| 63 | ;; `read-event' with a very short timeout. | 63 | ;; reading an input event, so, as a workaround, use a dummy |
| 64 | (unless noninteractive (read-event "" nil 0.1)) | 64 | ;; `read-event' with a very short timeout. |
| 65 | (while (and flymake-is-running (< (setq i (1+ i)) 10)) | ||
| 66 | (unless noninteractive (read-event "" nil 0.1)) | 65 | (unless noninteractive (read-event "" nil 0.1)) |
| 67 | (sleep-for (+ 0.5 flymake-no-changes-timeout))) | 66 | (while (and flymake-is-running (< (setq i (1+ i)) 10)) |
| 68 | (funcall fn)) | 67 | (unless noninteractive (read-event "" nil 0.1)) |
| 68 | (sleep-for (+ 0.5 flymake-no-changes-timeout))) | ||
| 69 | (funcall fn))) | ||
| 69 | (and buffer | 70 | (and buffer |
| 70 | (not visiting) | 71 | (not visiting) |
| 71 | (let (kill-buffer-query-functions) (kill-buffer buffer)))))) | 72 | (let (kill-buffer-query-functions) (kill-buffer buffer)))))) |
| @@ -114,6 +115,21 @@ SEVERITY-PREDICATE is used to setup | |||
| 114 | (should (eq 'flymake-warning | 115 | (should (eq 'flymake-warning |
| 115 | (face-at-point))))) | 116 | (face-at-point))))) |
| 116 | 117 | ||
| 118 | (ert-deftest errors-and-warnings () | ||
| 119 | "Test GCC warning via function predicate." | ||
| 120 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) | ||
| 121 | (flymake-tests--with-flymake | ||
| 122 | ("errors-and-warnings.c") | ||
| 123 | (flymake-goto-next-error) | ||
| 124 | (should (eq 'flymake-error (face-at-point))) | ||
| 125 | (flymake-goto-next-error) | ||
| 126 | (should (eq 'flymake-warning (face-at-point))) | ||
| 127 | (flymake-goto-next-error) | ||
| 128 | (should (eq 'flymake-warning (face-at-point))) | ||
| 129 | (flymake-goto-next-error) | ||
| 130 | (should (eq 'flymake-error (face-at-point))) | ||
| 131 | (should-error (flymake-goto-next-error nil t)) )) | ||
| 132 | |||
| 117 | (provide 'flymake-tests) | 133 | (provide 'flymake-tests) |
| 118 | 134 | ||
| 119 | ;;; flymake.el ends here | 135 | ;;; flymake.el ends here |