New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
;;; flymake-tests.el --- Test suite for flymake -*- lexical-binding: t -*-
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
2017-01-01 03:14:01 +00:00
|
|
|
|
;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
|
|
|
|
;; Author: Eduard Wiebe <usenet@pusto.de>
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
(require 'ert)
|
|
|
|
|
(require 'flymake)
|
|
|
|
|
|
2013-11-04 21:54:38 -05:00
|
|
|
|
(defvar flymake-tests-data-directory
|
2017-08-20 12:19:45 +01:00
|
|
|
|
(expand-file-name "lisp/progmodes/flymake-resources"
|
|
|
|
|
(or (getenv "EMACS_TEST_DIRECTORY")
|
|
|
|
|
(expand-file-name "../../.."
|
|
|
|
|
(or load-file-name
|
|
|
|
|
buffer-file-name))))
|
2013-11-04 21:54:38 -05:00
|
|
|
|
"Directory containing flymake test data.")
|
|
|
|
|
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
2017-09-07 14:19:33 +01:00
|
|
|
|
;;
|
|
|
|
|
;;
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(defun flymake-tests--wait-for-backends ()
|
|
|
|
|
;; 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))
|
|
|
|
|
(cl-loop repeat 5
|
|
|
|
|
for notdone = (cl-set-difference (flymake-running-backends)
|
|
|
|
|
(flymake-reporting-backends))
|
|
|
|
|
while notdone
|
|
|
|
|
unless noninteractive do (read-event "" nil 0.1)
|
|
|
|
|
do (sleep-for (+ 0.5 flymake-no-changes-timeout))
|
|
|
|
|
finally (when notdone (ert-fail
|
|
|
|
|
(format "Some backends not reporting yet %s"
|
|
|
|
|
notdone)))))
|
|
|
|
|
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(cl-defun flymake-tests--call-with-fixture (fn file
|
|
|
|
|
&key (severity-predicate
|
|
|
|
|
nil sev-pred-supplied-p))
|
|
|
|
|
"Call FN after flymake setup in FILE, using `flymake-proc`.
|
|
|
|
|
SEVERITY-PREDICATE is used to setup
|
2017-09-21 14:44:13 +01:00
|
|
|
|
`flymake-proc-diagnostic-type-pred'"
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(let* ((file (expand-file-name file flymake-tests-data-directory))
|
|
|
|
|
(visiting (find-buffer-visiting file))
|
|
|
|
|
(buffer (or visiting (find-file-noselect file)))
|
|
|
|
|
(process-environment (cons "LC_ALL=C" process-environment))
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(warning-minimum-log-level :error))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
(unwind-protect
|
2013-11-04 21:54:38 -05:00
|
|
|
|
(with-current-buffer buffer
|
2017-09-21 14:57:20 +01:00
|
|
|
|
(save-excursion
|
|
|
|
|
(when sev-pred-supplied-p
|
2017-09-21 14:44:13 +01:00
|
|
|
|
(setq-local flymake-proc-diagnostic-type-pred severity-predicate))
|
2017-09-21 14:57:20 +01:00
|
|
|
|
(goto-char (point-min))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
(unless flymake-mode (flymake-mode 1))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-tests--wait-for-backends)
|
2017-09-21 14:57:20 +01:00
|
|
|
|
(funcall fn)))
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(and buffer
|
|
|
|
|
(not visiting)
|
|
|
|
|
(let (kill-buffer-query-functions) (kill-buffer buffer))))))
|
|
|
|
|
|
|
|
|
|
(cl-defmacro flymake-tests--with-flymake ((file &rest args)
|
|
|
|
|
&body body)
|
|
|
|
|
(declare (indent 1)
|
|
|
|
|
(debug (sexp &rest form)))
|
|
|
|
|
`(flymake-tests--call-with-fixture (lambda () ,@body) ,file ,@args))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
2013-06-30 08:10:33 -07:00
|
|
|
|
(ert-deftest warning-predicate-rx-gcc ()
|
2013-06-21 10:36:13 -04:00
|
|
|
|
"Test GCC warning via regexp predicate."
|
2015-11-02 18:08:52 +01:00
|
|
|
|
(skip-unless (and (executable-find "gcc") (executable-find "make")))
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("test.c" :severity-predicate "^[Ww]arning")
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning
|
|
|
|
|
(face-at-point)))))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest warning-predicate-function-gcc ()
|
|
|
|
|
"Test GCC warning via function predicate."
|
2013-11-05 23:50:18 -08:00
|
|
|
|
(skip-unless (and (executable-find "gcc") (executable-find "make")))
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("test.c" :severity-predicate
|
|
|
|
|
(lambda (msg) (string-match "^[Ww]arning" msg)))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning
|
|
|
|
|
(face-at-point)))))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest warning-predicate-rx-perl ()
|
|
|
|
|
"Test perl warning via regular expression predicate."
|
2013-11-05 23:50:18 -08:00
|
|
|
|
(skip-unless (executable-find "perl"))
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("test.pl" :severity-predicate "^Scalar value")
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning
|
|
|
|
|
(face-at-point)))))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest warning-predicate-function-perl ()
|
|
|
|
|
"Test perl warning via function predicate."
|
2013-11-05 23:50:18 -08:00
|
|
|
|
(skip-unless (executable-find "perl"))
|
2017-09-07 14:19:33 +01:00
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("test.pl" :severity-predicate
|
|
|
|
|
(lambda (msg) (string-match "^Scalar value" msg)))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning
|
|
|
|
|
(face-at-point)))))
|
2013-06-21 10:36:13 -04:00
|
|
|
|
|
2017-09-21 14:44:13 +01:00
|
|
|
|
(ert-deftest different-diagnostic-types ()
|
2017-09-21 14:57:20 +01:00
|
|
|
|
"Test GCC warning via function predicate."
|
|
|
|
|
(skip-unless (and (executable-find "gcc") (executable-find "make")))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(let ((flymake-wrap-around nil))
|
|
|
|
|
(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-note (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)))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point)))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point)))
|
|
|
|
|
(should-error (flymake-goto-next-error nil nil t)))))
|
2017-09-28 12:06:56 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest included-c-header-files ()
|
|
|
|
|
"Test inclusion of .h header files."
|
|
|
|
|
(skip-unless (and (executable-find "gcc") (executable-find "make")))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(let ((flymake-wrap-around nil))
|
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("some-problems.h")
|
|
|
|
|
(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 nil t)))
|
|
|
|
|
(flymake-tests--with-flymake
|
|
|
|
|
("no-problems.h")
|
|
|
|
|
(should-error (flymake-goto-next-error nil nil t)))))
|
2017-09-21 14:57:20 +01:00
|
|
|
|
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
(defmacro flymake-tests--assert-set (set
|
|
|
|
|
should
|
|
|
|
|
should-not)
|
|
|
|
|
(declare (indent 1))
|
|
|
|
|
`(progn
|
|
|
|
|
,@(cl-loop
|
|
|
|
|
for s in should
|
2017-09-30 17:32:53 +01:00
|
|
|
|
collect `(should (memq (quote ,s) ,set)))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
,@(cl-loop
|
|
|
|
|
for s in should-not
|
2017-09-30 17:32:53 +01:00
|
|
|
|
collect `(should-not (memq (quote ,s) ,set)))))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(defun flymake-tests--diagnose-words
|
|
|
|
|
(report-fn type words)
|
|
|
|
|
"Helper. Call REPORT-FN with diagnostics for WORDS in buffer."
|
|
|
|
|
(funcall report-fn
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
(cl-loop
|
|
|
|
|
for word in words
|
|
|
|
|
append
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(cl-loop while (word-search-forward word nil t)
|
|
|
|
|
collect (flymake-make-diagnostic
|
|
|
|
|
(current-buffer)
|
|
|
|
|
(match-beginning 0)
|
|
|
|
|
(match-end 0)
|
|
|
|
|
type
|
|
|
|
|
(concat word " is wrong")))))))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest dummy-backends ()
|
|
|
|
|
"Test many different kinds of backends."
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(cl-letf
|
|
|
|
|
(((symbol-function 'error-backend)
|
|
|
|
|
(lambda (report-fn)
|
|
|
|
|
(run-with-timer
|
|
|
|
|
0.5 nil
|
|
|
|
|
#'flymake-tests--diagnose-words report-fn :error '("manha" "prognata"))))
|
|
|
|
|
((symbol-function 'warning-backend)
|
|
|
|
|
(lambda (report-fn)
|
|
|
|
|
(run-with-timer
|
|
|
|
|
0.5 nil
|
|
|
|
|
#'flymake-tests--diagnose-words report-fn :warning '("ut" "dolor"))))
|
|
|
|
|
((symbol-function 'sync-backend)
|
|
|
|
|
(lambda (report-fn)
|
|
|
|
|
(flymake-tests--diagnose-words report-fn :note '("quis" "commodo"))))
|
|
|
|
|
((symbol-function 'panicking-backend)
|
|
|
|
|
(lambda (report-fn)
|
|
|
|
|
(run-with-timer
|
|
|
|
|
0.5 nil
|
|
|
|
|
report-fn :panic :explanation "The spanish inquisition!")))
|
|
|
|
|
((symbol-function 'crashing-backend)
|
|
|
|
|
(lambda (_report-fn)
|
|
|
|
|
;; HACK: Shoosh log during tests
|
|
|
|
|
(setq-local warning-minimum-log-level :emergency)
|
|
|
|
|
(error "crashed"))))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
(insert "Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
|
|
|
elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
|
|
|
manha aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
|
|
|
consequat. Duis aute irure dolor in reprehenderit in
|
|
|
|
|
voluptate velit esse cillum dolore eu fugiat nulla
|
|
|
|
|
pariatur. Excepteur sint occaecat cupidatat non prognata
|
|
|
|
|
sunt in culpa qui officia deserunt mollit anim id est
|
|
|
|
|
laborum.")
|
|
|
|
|
(let ((flymake-diagnostic-functions
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(list 'error-backend 'warning-backend 'sync-backend
|
|
|
|
|
'panicking-backend
|
|
|
|
|
'crashing-backend
|
|
|
|
|
))
|
|
|
|
|
(flymake-wrap-around nil))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
(flymake-mode)
|
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-tests--assert-set (flymake-running-backends)
|
|
|
|
|
(error-backend warning-backend panicking-backend)
|
|
|
|
|
(crashing-backend))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-tests--assert-set (flymake-disabled-backends)
|
|
|
|
|
(crashing-backend)
|
|
|
|
|
(error-backend warning-backend sync-backend
|
|
|
|
|
panicking-backend))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-tests--wait-for-backends)
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-tests--assert-set (flymake-disabled-backends)
|
|
|
|
|
(crashing-backend panicking-backend)
|
|
|
|
|
(error-backend warning-backend sync-backend))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; dolor
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; ut
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-error (face-at-point))) ; manha
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; Ut
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-note (face-at-point))) ; quis
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; ut
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-note (face-at-point))) ; commodo
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; dolor
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-error (face-at-point))) ; prognata
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(should-error (flymake-goto-next-error nil nil t))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest recurrent-backend ()
|
|
|
|
|
"Test a backend that calls REPORT-FN multiple times"
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(let (tick)
|
|
|
|
|
(cl-letf
|
|
|
|
|
(((symbol-function 'eager-backend)
|
|
|
|
|
(lambda (report-fn)
|
|
|
|
|
(funcall report-fn nil :explanation "very eager but no diagnostics")
|
|
|
|
|
(display-buffer (current-buffer))
|
|
|
|
|
(run-with-timer
|
|
|
|
|
0.5 nil
|
|
|
|
|
(lambda ()
|
|
|
|
|
(flymake-tests--diagnose-words report-fn :warning '("consectetur"))
|
|
|
|
|
(setq tick t)
|
|
|
|
|
(run-with-timer
|
|
|
|
|
0.5 nil
|
|
|
|
|
(lambda ()
|
|
|
|
|
(flymake-tests--diagnose-words report-fn :error '("fugiat"))
|
|
|
|
|
(setq tick t))))))))
|
|
|
|
|
(insert "Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
|
|
|
elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
|
|
|
manha aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
|
|
|
consequat. Duis aute irure dolor in reprehenderit in
|
|
|
|
|
voluptate velit esse cillum dolore eu fugiat nulla
|
|
|
|
|
pariatur. Excepteur sint occaecat cupidatat non prognata
|
|
|
|
|
sunt in culpa qui officia deserunt mollit anim id est
|
|
|
|
|
laborum.")
|
|
|
|
|
(let ((flymake-diagnostic-functions
|
|
|
|
|
(list 'eager-backend))
|
|
|
|
|
(flymake-wrap-around nil))
|
|
|
|
|
(flymake-mode)
|
|
|
|
|
(flymake-tests--assert-set (flymake-running-backends)
|
|
|
|
|
(eager-backend) ())
|
|
|
|
|
(cl-loop until tick repeat 4 do (sleep-for 0.2))
|
|
|
|
|
(setq tick nil)
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(flymake-goto-prev-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; consectetur
|
|
|
|
|
(should-error (flymake-goto-prev-error nil nil t))
|
|
|
|
|
(cl-loop until tick repeat 4 do (sleep-for 0.2))
|
|
|
|
|
(flymake-goto-next-error)
|
|
|
|
|
(should (eq 'flymake-error (face-at-point))) ; fugiat
|
|
|
|
|
(flymake-goto-prev-error)
|
|
|
|
|
(should (eq 'flymake-warning (face-at-point))) ; back at consectetur
|
|
|
|
|
(should-error (flymake-goto-prev-error nil nil t))
|
|
|
|
|
)))))
|
New Flymake API variable flymake-diagnostic-functions
Lay groundwork for multiple active backends in the same buffer.
Backends are lisp functions called when flymake-mode sees fit. They
are responsible for examining the current buffer and telling
flymake.el, via return value, if they can syntax check it.
Backends should return quickly and inexpensively, but they are also
passed a REPORT-FN argument which they may or may not call
asynchronously after performing more expensive work.
REPORT-FN's calling convention stipulates that a backend calls it with
a list of diagnostics as argument, or, alternatively, with a symbol
denoting an exceptional situation, usually some panic resulting from a
misconfigured backend. In keeping with legacy behaviour,
flymake.el's response to a panic is to disable the issuing backend.
The flymake--diag object representing a diagnostic now also keeps
information about its source backend. Among other uses, this allows
flymake to selectively cleanup overlays based on which backend is
updating its diagnostics.
* lisp/progmodes/flymake-proc.el (flymake-proc--report-fn):
New dynamic variable.
(flymake-proc--process): New variable.
(flymake-can-syntax-check-buffer): Remove.
(flymake-proc--process-sentinel): Simplify. Use
unwind-protect. Affect flymake-proc--processes here.
Bind flymake-proc--report-fn.
(flymake-proc--process-filter): Bind flymake-proc--report-fn.
(flymake-proc--post-syntax-check): Delete
(flymake-proc-start-syntax-check): Take mandatory
report-fn. Rewrite. Bind flymake-proc--report-fn.
(flymake-proc--process-sentinel): Rewrite and simplify.
(flymake-proc--panic): New helper.
(flymake-proc--start-syntax-check-process): Record report-fn
in process. Use flymake-proc--panic.
(flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect
flymake-proc--processes here. Record interruption reason.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
Use flymake-proc--panic.
(flymake-diagnostic-functions): Add
flymake-proc-start-syntax-check.
(flymake-proc-compile): Call
flymake-proc-stop-all-syntax-checks with a reason.
* lisp/progmodes/flymake.el (flymake-backends): Delete.
(flymake-check-was-interrupted): Delete.
(flymake--diag): Add backend slot.
(flymake-delete-own-overlays): Take optional filter arg.
(flymake-diagnostic-functions): New user-visible variable.
(flymake--running-backends, flymake--disabled-backends): New
buffer-local variables.
(flymake-is-running): Now a function, not a variable.
(flymake-mode-line, flymake-mode-line-e-w)
(flymake-mode-line-status): Delete.
(flymake-lighter): flymake's minor-mode "lighter".
(flymake-report): Delete.
(flymake--backend): Delete.
(flymake--can-syntax-check-buffer): Delete.
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake--run-backend): New helpers.
(flymake-make-report-fn): Make a lambda.
(flymake--start-syntax-check): Iterate
flymake-diagnostic-functions.
(flymake-mode): Use flymake-lighter. Simplify. Initialize
flymake--running-backends and flymake--disabled-backends.
(flymake-find-file-hook): Simplify.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Use flymake-is-running the
function. Check if flymake-mode already active before activating it.
Add a thorough test for flymake multiple backends
* lisp/progmodes/flymake.el (flymake--start-syntax-check):
Don't use condition-case-unless-debug, use condition-case
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--assert-set): New helper macro.
(dummy-backends): New test.
2017-09-26 00:45:46 +01:00
|
|
|
|
|
2013-06-21 10:36:13 -04:00
|
|
|
|
(provide 'flymake-tests)
|
|
|
|
|
|
|
|
|
|
;;; flymake.el ends here
|