mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
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.
This commit is contained in:
parent
7787988587
commit
0d26e45ab4
2 changed files with 42 additions and 16 deletions
10
test/lisp/progmodes/flymake-resources/errors-and-warnings.c
Normal file
10
test/lisp/progmodes/flymake-resources/errors-and-warnings.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
int main()
|
||||
{
|
||||
char c = 1000;
|
||||
int bla;
|
||||
/* The following line should have one warning and one error. The
|
||||
warning spans the full line because gcc (at least 6.3.0) points
|
||||
places the error at the =, which isn't a sexp.*/
|
||||
char c; if (bla == (void*)3);
|
||||
return c;
|
||||
}
|
||||
|
|
@ -49,23 +49,24 @@ SEVERITY-PREDICATE is used to setup
|
|||
(i 0))
|
||||
(unwind-protect
|
||||
(with-current-buffer buffer
|
||||
(when sev-pred-supplied-p
|
||||
(setq-local flymake-proc-warning-predicate severity-predicate))
|
||||
(goto-char (point-min))
|
||||
(flymake-mode 1)
|
||||
;; Weirdness here... http://debbugs.gnu.org/17647#25
|
||||
;; ... meaning `sleep-for', and even
|
||||
;; `accept-process-output', won't suffice as ways to get
|
||||
;; process filters and sentinels to run, though they do work
|
||||
;; fine in a non-interactive batch session. The only thing
|
||||
;; that will indeed unblock pending process output is
|
||||
;; reading an input event, so, as a workaround, use a dummy
|
||||
;; `read-event' with a very short timeout.
|
||||
(unless noninteractive (read-event "" nil 0.1))
|
||||
(while (and flymake-is-running (< (setq i (1+ i)) 10))
|
||||
(save-excursion
|
||||
(when sev-pred-supplied-p
|
||||
(setq-local flymake-proc-warning-predicate severity-predicate))
|
||||
(goto-char (point-min))
|
||||
(flymake-mode 1)
|
||||
;; Weirdness here... http://debbugs.gnu.org/17647#25
|
||||
;; ... meaning `sleep-for', and even
|
||||
;; `accept-process-output', won't suffice as ways to get
|
||||
;; process filters and sentinels to run, though they do work
|
||||
;; fine in a non-interactive batch session. The only thing
|
||||
;; that will indeed unblock pending process output is
|
||||
;; reading an input event, so, as a workaround, use a dummy
|
||||
;; `read-event' with a very short timeout.
|
||||
(unless noninteractive (read-event "" nil 0.1))
|
||||
(sleep-for (+ 0.5 flymake-no-changes-timeout)))
|
||||
(funcall fn))
|
||||
(while (and flymake-is-running (< (setq i (1+ i)) 10))
|
||||
(unless noninteractive (read-event "" nil 0.1))
|
||||
(sleep-for (+ 0.5 flymake-no-changes-timeout)))
|
||||
(funcall fn)))
|
||||
(and buffer
|
||||
(not visiting)
|
||||
(let (kill-buffer-query-functions) (kill-buffer buffer))))))
|
||||
|
|
@ -114,6 +115,21 @@ SEVERITY-PREDICATE is used to setup
|
|||
(should (eq 'flymake-warning
|
||||
(face-at-point)))))
|
||||
|
||||
(ert-deftest errors-and-warnings ()
|
||||
"Test GCC warning via function predicate."
|
||||
(skip-unless (and (executable-find "gcc") (executable-find "make")))
|
||||
(flymake-tests--with-flymake
|
||||
("errors-and-warnings.c")
|
||||
(flymake-goto-next-error)
|
||||
(should (eq 'flymake-error (face-at-point)))
|
||||
(flymake-goto-next-error)
|
||||
(should (eq 'flymake-warning (face-at-point)))
|
||||
(flymake-goto-next-error)
|
||||
(should (eq 'flymake-warning (face-at-point)))
|
||||
(flymake-goto-next-error)
|
||||
(should (eq 'flymake-error (face-at-point)))
|
||||
(should-error (flymake-goto-next-error nil t)) ))
|
||||
|
||||
(provide 'flymake-tests)
|
||||
|
||||
;;; flymake.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue