diff options
| author | Stefan Monnier | 2017-10-06 09:50:54 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2017-10-06 09:50:54 -0400 |
| commit | 11f9cb522fed9aa6552f6315340ca7352661a1e8 (patch) | |
| tree | 39facc48471c67b321c045e47d70ef030adbea44 /test | |
| parent | 92045f4546b9708dc9f69954799d211c1f56ff1e (diff) | |
| parent | 9655937da4a339300c624addd97674c038a01bc9 (diff) | |
| download | emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.tar.gz emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.zip | |
Merge emacs-26
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/generator-tests.el | 10 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 29 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-resources/Makefile | 4 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-resources/errors-and-warnings.c | 13 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-resources/no-problems.h | 1 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-resources/some-problems.h | 5 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-tests.el | 297 |
7 files changed, 323 insertions, 36 deletions
diff --git a/test/lisp/emacs-lisp/generator-tests.el b/test/lisp/emacs-lisp/generator-tests.el index 4cc6c841dac..cbb136ae919 100644 --- a/test/lisp/emacs-lisp/generator-tests.el +++ b/test/lisp/emacs-lisp/generator-tests.el | |||
| @@ -282,3 +282,13 @@ identical output. | |||
| 282 | (ert-deftest cps-test-declarations-preserved () | 282 | (ert-deftest cps-test-declarations-preserved () |
| 283 | (should (equal (documentation 'generator-with-docstring) "Documentation!")) | 283 | (should (equal (documentation 'generator-with-docstring) "Documentation!")) |
| 284 | (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5))) | 284 | (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5))) |
| 285 | |||
| 286 | (ert-deftest cps-iter-lambda-with-dynamic-binding () | ||
| 287 | "`iter-lambda' with dynamic binding produces correct result (bug#25965)." | ||
| 288 | (should (= 1 | ||
| 289 | (iter-next | ||
| 290 | (funcall (iter-lambda () | ||
| 291 | (let* ((fill-column 10) ;;any special variable will do | ||
| 292 | (i 0) | ||
| 293 | (j (setq i (1+ i)))) | ||
| 294 | (iter-yield i)))))))) | ||
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d430caec8aa..a8fe06d4e67 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -3438,7 +3438,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3438 | (fboundp 'connection-local-set-profiles))) | 3438 | (fboundp 'connection-local-set-profiles))) |
| 3439 | 3439 | ||
| 3440 | ;; `connection-local-set-profile-variables' and | 3440 | ;; `connection-local-set-profile-variables' and |
| 3441 | ;; `connection-local-set-profiles' exists since Emacs 26. We don't | 3441 | ;; `connection-local-set-profiles' exist since Emacs 26. We don't |
| 3442 | ;; want to see compiler warnings for older Emacsen. | 3442 | ;; want to see compiler warnings for older Emacsen. |
| 3443 | (let ((default-directory tramp-test-temporary-file-directory) | 3443 | (let ((default-directory tramp-test-temporary-file-directory) |
| 3444 | explicit-shell-file-name kill-buffer-query-functions) | 3444 | explicit-shell-file-name kill-buffer-query-functions) |
| @@ -4108,12 +4108,29 @@ Use the `ls' command." | |||
| 4108 | tramp-connection-properties))) | 4108 | tramp-connection-properties))) |
| 4109 | (tramp--test-utf8))) | 4109 | (tramp--test-utf8))) |
| 4110 | 4110 | ||
| 4111 | (ert-deftest tramp-test37-file-system-info () | ||
| 4112 | "Check that `file-system-info' returns proper values." | ||
| 4113 | (skip-unless (tramp--test-enabled)) | ||
| 4114 | ;; Since Emacs 27.1. | ||
| 4115 | (skip-unless (fboundp 'file-system-info)) | ||
| 4116 | |||
| 4117 | ;; `file-system-info' exists since Emacs 27. We don't | ||
| 4118 | ;; want to see compiler warnings for older Emacsen. | ||
| 4119 | (let ((fsi (with-no-warnings | ||
| 4120 | (file-system-info tramp-test-temporary-file-directory)))) | ||
| 4121 | (skip-unless fsi) | ||
| 4122 | (should (and (consp fsi) | ||
| 4123 | (= (length fsi) 3) | ||
| 4124 | (numberp (nth 0 fsi)) | ||
| 4125 | (numberp (nth 1 fsi)) | ||
| 4126 | (numberp (nth 2 fsi)))))) | ||
| 4127 | |||
| 4111 | (defun tramp--test-timeout-handler () | 4128 | (defun tramp--test-timeout-handler () |
| 4112 | (interactive) | 4129 | (interactive) |
| 4113 | (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test))))) | 4130 | (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test))))) |
| 4114 | 4131 | ||
| 4115 | ;; This test is inspired by Bug#16928. | 4132 | ;; This test is inspired by Bug#16928. |
| 4116 | (ert-deftest tramp-test37-asynchronous-requests () | 4133 | (ert-deftest tramp-test38-asynchronous-requests () |
| 4117 | "Check parallel asynchronous requests. | 4134 | "Check parallel asynchronous requests. |
| 4118 | Such requests could arrive from timers, process filters and | 4135 | Such requests could arrive from timers, process filters and |
| 4119 | process sentinels. They shall not disturb each other." | 4136 | process sentinels. They shall not disturb each other." |
| @@ -4270,7 +4287,7 @@ process sentinels. They shall not disturb each other." | |||
| 4270 | (ignore-errors (cancel-timer timer)) | 4287 | (ignore-errors (cancel-timer timer)) |
| 4271 | (ignore-errors (delete-directory tmp-name 'recursive))))))) | 4288 | (ignore-errors (delete-directory tmp-name 'recursive))))))) |
| 4272 | 4289 | ||
| 4273 | (ert-deftest tramp-test38-recursive-load () | 4290 | (ert-deftest tramp-test39-recursive-load () |
| 4274 | "Check that Tramp does not fail due to recursive load." | 4291 | "Check that Tramp does not fail due to recursive load." |
| 4275 | (skip-unless (tramp--test-enabled)) | 4292 | (skip-unless (tramp--test-enabled)) |
| 4276 | 4293 | ||
| @@ -4293,7 +4310,7 @@ process sentinels. They shall not disturb each other." | |||
| 4293 | (mapconcat 'shell-quote-argument load-path " -L ") | 4310 | (mapconcat 'shell-quote-argument load-path " -L ") |
| 4294 | (shell-quote-argument code)))))))) | 4311 | (shell-quote-argument code)))))))) |
| 4295 | 4312 | ||
| 4296 | (ert-deftest tramp-test39-remote-load-path () | 4313 | (ert-deftest tramp-test40-remote-load-path () |
| 4297 | "Check that Tramp autoloads its packages with remote `load-path'." | 4314 | "Check that Tramp autoloads its packages with remote `load-path'." |
| 4298 | ;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el. | 4315 | ;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el. |
| 4299 | ;; It shall still work, when a remote file name is in the | 4316 | ;; It shall still work, when a remote file name is in the |
| @@ -4316,7 +4333,7 @@ process sentinels. They shall not disturb each other." | |||
| 4316 | (mapconcat 'shell-quote-argument load-path " -L ") | 4333 | (mapconcat 'shell-quote-argument load-path " -L ") |
| 4317 | (shell-quote-argument code))))))) | 4334 | (shell-quote-argument code))))))) |
| 4318 | 4335 | ||
| 4319 | (ert-deftest tramp-test40-unload () | 4336 | (ert-deftest tramp-test41-unload () |
| 4320 | "Check that Tramp and its subpackages unload completely. | 4337 | "Check that Tramp and its subpackages unload completely. |
| 4321 | Since it unloads Tramp, it shall be the last test to run." | 4338 | Since it unloads Tramp, it shall be the last test to run." |
| 4322 | :tags '(:expensive-test) | 4339 | :tags '(:expensive-test) |
| @@ -4374,7 +4391,7 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 4374 | ;; * Fix `tramp-test05-expand-file-name-relative' in `expand-file-name'. | 4391 | ;; * Fix `tramp-test05-expand-file-name-relative' in `expand-file-name'. |
| 4375 | ;; * Fix `tramp-test06-directory-file-name' for `ftp'. | 4392 | ;; * Fix `tramp-test06-directory-file-name' for `ftp'. |
| 4376 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). | 4393 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). |
| 4377 | ;; * Fix Bug#16928 in `tramp-test37-asynchronous-requests'. | 4394 | ;; * Fix Bug#16928 in `tramp-test38-asynchronous-requests'. |
| 4378 | 4395 | ||
| 4379 | (defun tramp-test-all (&optional interactive) | 4396 | (defun tramp-test-all (&optional interactive) |
| 4380 | "Run all tests for \\[tramp]." | 4397 | "Run all tests for \\[tramp]." |
diff --git a/test/lisp/progmodes/flymake-resources/Makefile b/test/lisp/progmodes/flymake-resources/Makefile index 0f3f39791c8..494407567f2 100644 --- a/test/lisp/progmodes/flymake-resources/Makefile +++ b/test/lisp/progmodes/flymake-resources/Makefile | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Makefile for flymake tests | 1 | # Makefile for flymake tests |
| 2 | 2 | ||
| 3 | CC_OPTS = -Wall | 3 | CC_OPTS = -Wall -Wextra |
| 4 | 4 | ||
| 5 | ## Recent gcc (e.g. 4.8.2 on RHEL7) can automatically colorize their output, | 5 | ## Recent gcc (e.g. 4.8.2 on RHEL7) can automatically colorize their output, |
| 6 | ## which can confuse flymake. Set GCC_COLORS to disable that. | 6 | ## which can confuse flymake. Set GCC_COLORS to disable that. |
| @@ -8,6 +8,6 @@ CC_OPTS = -Wall | |||
| 8 | ## normally use flymake, so it seems like just avoiding the issue | 8 | ## normally use flymake, so it seems like just avoiding the issue |
| 9 | ## in this test is fine. Set flymake-log-level to 3 to investigate. | 9 | ## in this test is fine. Set flymake-log-level to 3 to investigate. |
| 10 | check-syntax: | 10 | check-syntax: |
| 11 | GCC_COLORS= $(CC) $(CC_OPTS) ${CHK_SOURCES} | 11 | GCC_COLORS= $(CC) $(CC_OPTS) ${CHK_SOURCES} || true |
| 12 | 12 | ||
| 13 | # eof | 13 | # eof |
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..1d38bd6bd27 --- /dev/null +++ b/test/lisp/progmodes/flymake-resources/errors-and-warnings.c | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | /* Flymake should notice an error on the next line, since | ||
| 2 | that file has at least one warning.*/ | ||
| 3 | #include "some-problems.h" | ||
| 4 | /* But not this one */ | ||
| 5 | #include "no-problems.h" | ||
| 6 | |||
| 7 | int main() | ||
| 8 | { | ||
| 9 | char c = 1000; /* a note and a warning */ | ||
| 10 | int bla; | ||
| 11 | char c; if (bla == (void*)3); /* an error, and two warnings */ | ||
| 12 | return c; | ||
| 13 | } | ||
diff --git a/test/lisp/progmodes/flymake-resources/no-problems.h b/test/lisp/progmodes/flymake-resources/no-problems.h new file mode 100644 index 00000000000..19ddc615b32 --- /dev/null +++ b/test/lisp/progmodes/flymake-resources/no-problems.h | |||
| @@ -0,0 +1 @@ | |||
| typedef int no_problems; | |||
diff --git a/test/lisp/progmodes/flymake-resources/some-problems.h b/test/lisp/progmodes/flymake-resources/some-problems.h new file mode 100644 index 00000000000..165d8dd525e --- /dev/null +++ b/test/lisp/progmodes/flymake-resources/some-problems.h | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | strange; | ||
| 4 | |||
| 5 | sint main(); | ||
diff --git a/test/lisp/progmodes/flymake-tests.el b/test/lisp/progmodes/flymake-tests.el index b04346fd97c..5e042f2b082 100644 --- a/test/lisp/progmodes/flymake-tests.el +++ b/test/lisp/progmodes/flymake-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; flymake-tests.el --- Test suite for flymake | 1 | ;;; flymake-tests.el --- Test suite for flymake -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2011-2017 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2011-2017 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -26,54 +26,295 @@ | |||
| 26 | (require 'flymake) | 26 | (require 'flymake) |
| 27 | 27 | ||
| 28 | (defvar flymake-tests-data-directory | 28 | (defvar flymake-tests-data-directory |
| 29 | (expand-file-name "lisp/progmodes/flymake-resources" (getenv "EMACS_TEST_DIRECTORY")) | 29 | (expand-file-name "lisp/progmodes/flymake-resources" |
| 30 | (or (getenv "EMACS_TEST_DIRECTORY") | ||
| 31 | (expand-file-name "../../.." | ||
| 32 | (or load-file-name | ||
| 33 | buffer-file-name)))) | ||
| 30 | "Directory containing flymake test data.") | 34 | "Directory containing flymake test data.") |
| 31 | 35 | ||
| 32 | 36 | ||
| 33 | ;; Warning predicate | 37 | ;; |
| 34 | (defun flymake-tests--current-face (file predicate) | 38 | ;; |
| 35 | (let ((buffer (find-file-noselect | 39 | (defun flymake-tests--wait-for-backends () |
| 36 | (expand-file-name file flymake-tests-data-directory))) | 40 | ;; Weirdness here... http://debbugs.gnu.org/17647#25 |
| 37 | (process-environment (cons "LC_ALL=C" process-environment)) | 41 | ;; ... meaning `sleep-for', and even |
| 38 | (i 0)) | 42 | ;; `accept-process-output', won't suffice as ways to get |
| 43 | ;; process filters and sentinels to run, though they do work | ||
| 44 | ;; fine in a non-interactive batch session. The only thing | ||
| 45 | ;; that will indeed unblock pending process output is | ||
| 46 | ;; reading an input event, so, as a workaround, use a dummy | ||
| 47 | ;; `read-event' with a very short timeout. | ||
| 48 | (unless noninteractive (read-event "" nil 0.1)) | ||
| 49 | (cl-loop repeat 5 | ||
| 50 | for notdone = (cl-set-difference (flymake-running-backends) | ||
| 51 | (flymake-reporting-backends)) | ||
| 52 | while notdone | ||
| 53 | unless noninteractive do (read-event "" nil 0.1) | ||
| 54 | do (sleep-for (+ 0.5 flymake-no-changes-timeout)) | ||
| 55 | finally (when notdone (ert-fail | ||
| 56 | (format "Some backends not reporting yet %s" | ||
| 57 | notdone))))) | ||
| 58 | |||
| 59 | (cl-defun flymake-tests--call-with-fixture (fn file | ||
| 60 | &key (severity-predicate | ||
| 61 | nil sev-pred-supplied-p)) | ||
| 62 | "Call FN after flymake setup in FILE, using `flymake-proc`. | ||
| 63 | SEVERITY-PREDICATE is used to setup | ||
| 64 | `flymake-proc-diagnostic-type-pred'" | ||
| 65 | (let* ((file (expand-file-name file flymake-tests-data-directory)) | ||
| 66 | (visiting (find-buffer-visiting file)) | ||
| 67 | (buffer (or visiting (find-file-noselect file))) | ||
| 68 | (process-environment (cons "LC_ALL=C" process-environment)) | ||
| 69 | (warning-minimum-log-level :error)) | ||
| 39 | (unwind-protect | 70 | (unwind-protect |
| 40 | (with-current-buffer buffer | 71 | (with-current-buffer buffer |
| 41 | (setq-local flymake-warning-predicate predicate) | 72 | (save-excursion |
| 42 | (goto-char (point-min)) | 73 | (when sev-pred-supplied-p |
| 43 | (flymake-mode 1) | 74 | (setq-local flymake-proc-diagnostic-type-pred severity-predicate)) |
| 44 | ;; Weirdness here... https://debbugs.gnu.org/17647#25 | 75 | (goto-char (point-min)) |
| 45 | (while (and flymake-is-running (< (setq i (1+ i)) 10)) | 76 | (unless flymake-mode (flymake-mode 1)) |
| 46 | (sleep-for (+ 0.5 flymake-no-changes-timeout))) | 77 | (flymake-tests--wait-for-backends) |
| 47 | (flymake-goto-next-error) | 78 | (funcall fn))) |
| 48 | (face-at-point)) | 79 | (and buffer |
| 49 | (and buffer (let (kill-buffer-query-functions) (kill-buffer buffer)))))) | 80 | (not visiting) |
| 81 | (let (kill-buffer-query-functions) (kill-buffer buffer)))))) | ||
| 82 | |||
| 83 | (cl-defmacro flymake-tests--with-flymake ((file &rest args) | ||
| 84 | &body body) | ||
| 85 | (declare (indent 1) | ||
| 86 | (debug (sexp &rest form))) | ||
| 87 | `(flymake-tests--call-with-fixture (lambda () ,@body) ,file ,@args)) | ||
| 50 | 88 | ||
| 51 | (ert-deftest warning-predicate-rx-gcc () | 89 | (ert-deftest warning-predicate-rx-gcc () |
| 52 | "Test GCC warning via regexp predicate." | 90 | "Test GCC warning via regexp predicate." |
| 53 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) | 91 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) |
| 54 | (should (eq 'flymake-warnline | 92 | (flymake-tests--with-flymake |
| 55 | (flymake-tests--current-face "test.c" "^[Ww]arning")))) | 93 | ("test.c" :severity-predicate "^[Ww]arning") |
| 94 | (flymake-goto-next-error) | ||
| 95 | (should (eq 'flymake-warning | ||
| 96 | (face-at-point))))) | ||
| 56 | 97 | ||
| 57 | (ert-deftest warning-predicate-function-gcc () | 98 | (ert-deftest warning-predicate-function-gcc () |
| 58 | "Test GCC warning via function predicate." | 99 | "Test GCC warning via function predicate." |
| 59 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) | 100 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) |
| 60 | (should (eq 'flymake-warnline | 101 | (flymake-tests--with-flymake |
| 61 | (flymake-tests--current-face "test.c" | 102 | ("test.c" :severity-predicate |
| 62 | (lambda (msg) (string-match "^[Ww]arning" msg)))))) | 103 | (lambda (msg) (string-match "^[Ww]arning" msg))) |
| 104 | (flymake-goto-next-error) | ||
| 105 | (should (eq 'flymake-warning | ||
| 106 | (face-at-point))))) | ||
| 63 | 107 | ||
| 64 | (ert-deftest warning-predicate-rx-perl () | 108 | (ert-deftest warning-predicate-rx-perl () |
| 65 | "Test perl warning via regular expression predicate." | 109 | "Test perl warning via regular expression predicate." |
| 66 | (skip-unless (executable-find "perl")) | 110 | (skip-unless (executable-find "perl")) |
| 67 | (should (eq 'flymake-warnline | 111 | (flymake-tests--with-flymake |
| 68 | (flymake-tests--current-face "test.pl" "^Scalar value")))) | 112 | ("test.pl" :severity-predicate "^Scalar value") |
| 113 | (flymake-goto-next-error) | ||
| 114 | (should (eq 'flymake-warning | ||
| 115 | (face-at-point))))) | ||
| 69 | 116 | ||
| 70 | (ert-deftest warning-predicate-function-perl () | 117 | (ert-deftest warning-predicate-function-perl () |
| 71 | "Test perl warning via function predicate." | 118 | "Test perl warning via function predicate." |
| 72 | (skip-unless (executable-find "perl")) | 119 | (skip-unless (executable-find "perl")) |
| 73 | (should (eq 'flymake-warnline | 120 | (flymake-tests--with-flymake |
| 74 | (flymake-tests--current-face | 121 | ("test.pl" :severity-predicate |
| 75 | "test.pl" | 122 | (lambda (msg) (string-match "^Scalar value" msg))) |
| 76 | (lambda (msg) (string-match "^Scalar value" msg)))))) | 123 | (flymake-goto-next-error) |
| 124 | (should (eq 'flymake-warning | ||
| 125 | (face-at-point))))) | ||
| 126 | |||
| 127 | (ert-deftest different-diagnostic-types () | ||
| 128 | "Test GCC warning via function predicate." | ||
| 129 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) | ||
| 130 | (let ((flymake-wrap-around nil)) | ||
| 131 | (flymake-tests--with-flymake | ||
| 132 | ("errors-and-warnings.c") | ||
| 133 | (flymake-goto-next-error) | ||
| 134 | (should (eq 'flymake-error (face-at-point))) | ||
| 135 | (flymake-goto-next-error) | ||
| 136 | (should (eq 'flymake-note (face-at-point))) | ||
| 137 | (flymake-goto-next-error) | ||
| 138 | (should (eq 'flymake-warning (face-at-point))) | ||
| 139 | (flymake-goto-next-error) | ||
| 140 | (should (eq 'flymake-error (face-at-point))) | ||
| 141 | (flymake-goto-next-error) | ||
| 142 | (should (eq 'flymake-warning (face-at-point))) | ||
| 143 | (flymake-goto-next-error) | ||
| 144 | (should (eq 'flymake-warning (face-at-point))) | ||
| 145 | (should-error (flymake-goto-next-error nil nil t))))) | ||
| 146 | |||
| 147 | (ert-deftest included-c-header-files () | ||
| 148 | "Test inclusion of .h header files." | ||
| 149 | (skip-unless (and (executable-find "gcc") (executable-find "make"))) | ||
| 150 | (let ((flymake-wrap-around nil)) | ||
| 151 | (flymake-tests--with-flymake | ||
| 152 | ("some-problems.h") | ||
| 153 | (flymake-goto-next-error) | ||
| 154 | (should (eq 'flymake-warning (face-at-point))) | ||
| 155 | (flymake-goto-next-error) | ||
| 156 | (should (eq 'flymake-error (face-at-point))) | ||
| 157 | (should-error (flymake-goto-next-error nil nil t))) | ||
| 158 | (flymake-tests--with-flymake | ||
| 159 | ("no-problems.h") | ||
| 160 | (should-error (flymake-goto-next-error nil nil t))))) | ||
| 161 | |||
| 162 | (defmacro flymake-tests--assert-set (set | ||
| 163 | should | ||
| 164 | should-not) | ||
| 165 | (declare (indent 1)) | ||
| 166 | `(progn | ||
| 167 | ,@(cl-loop | ||
| 168 | for s in should | ||
| 169 | collect `(should (memq (quote ,s) ,set))) | ||
| 170 | ,@(cl-loop | ||
| 171 | for s in should-not | ||
| 172 | collect `(should-not (memq (quote ,s) ,set))))) | ||
| 173 | |||
| 174 | (defun flymake-tests--diagnose-words | ||
| 175 | (report-fn type words) | ||
| 176 | "Helper. Call REPORT-FN with diagnostics for WORDS in buffer." | ||
| 177 | (funcall report-fn | ||
| 178 | (cl-loop | ||
| 179 | for word in words | ||
| 180 | append | ||
| 181 | (save-excursion | ||
| 182 | (goto-char (point-min)) | ||
| 183 | (cl-loop while (word-search-forward word nil t) | ||
| 184 | collect (flymake-make-diagnostic | ||
| 185 | (current-buffer) | ||
| 186 | (match-beginning 0) | ||
| 187 | (match-end 0) | ||
| 188 | type | ||
| 189 | (concat word " is wrong"))))))) | ||
| 190 | |||
| 191 | (ert-deftest dummy-backends () | ||
| 192 | "Test many different kinds of backends." | ||
| 193 | (with-temp-buffer | ||
| 194 | (cl-letf | ||
| 195 | (((symbol-function 'error-backend) | ||
| 196 | (lambda (report-fn) | ||
| 197 | (run-with-timer | ||
| 198 | 0.5 nil | ||
| 199 | #'flymake-tests--diagnose-words report-fn :error '("manha" "prognata")))) | ||
| 200 | ((symbol-function 'warning-backend) | ||
| 201 | (lambda (report-fn) | ||
| 202 | (run-with-timer | ||
| 203 | 0.5 nil | ||
| 204 | #'flymake-tests--diagnose-words report-fn :warning '("ut" "dolor")))) | ||
| 205 | ((symbol-function 'sync-backend) | ||
| 206 | (lambda (report-fn) | ||
| 207 | (flymake-tests--diagnose-words report-fn :note '("quis" "commodo")))) | ||
| 208 | ((symbol-function 'panicking-backend) | ||
| 209 | (lambda (report-fn) | ||
| 210 | (run-with-timer | ||
| 211 | 0.5 nil | ||
| 212 | report-fn :panic :explanation "The spanish inquisition!"))) | ||
| 213 | ((symbol-function 'crashing-backend) | ||
| 214 | (lambda (_report-fn) | ||
| 215 | ;; HACK: Shoosh log during tests | ||
| 216 | (setq-local warning-minimum-log-level :emergency) | ||
| 217 | (error "crashed")))) | ||
| 218 | (insert "Lorem ipsum dolor sit amet, consectetur adipiscing | ||
| 219 | elit, sed do eiusmod tempor incididunt ut labore et dolore | ||
| 220 | manha aliqua. Ut enim ad minim veniam, quis nostrud | ||
| 221 | exercitation ullamco laboris nisi ut aliquip ex ea commodo | ||
| 222 | consequat. Duis aute irure dolor in reprehenderit in | ||
| 223 | voluptate velit esse cillum dolore eu fugiat nulla | ||
| 224 | pariatur. Excepteur sint occaecat cupidatat non prognata | ||
| 225 | sunt in culpa qui officia deserunt mollit anim id est | ||
| 226 | laborum.") | ||
| 227 | (let ((flymake-diagnostic-functions | ||
| 228 | (list 'error-backend 'warning-backend 'sync-backend | ||
| 229 | 'panicking-backend | ||
| 230 | 'crashing-backend | ||
| 231 | )) | ||
| 232 | (flymake-wrap-around nil)) | ||
| 233 | (flymake-mode) | ||
| 234 | |||
| 235 | (flymake-tests--assert-set (flymake-running-backends) | ||
| 236 | (error-backend warning-backend panicking-backend) | ||
| 237 | (crashing-backend)) | ||
| 238 | |||
| 239 | (flymake-tests--assert-set (flymake-disabled-backends) | ||
| 240 | (crashing-backend) | ||
| 241 | (error-backend warning-backend sync-backend | ||
| 242 | panicking-backend)) | ||
| 243 | |||
| 244 | (flymake-tests--wait-for-backends) | ||
| 245 | |||
| 246 | (flymake-tests--assert-set (flymake-disabled-backends) | ||
| 247 | (crashing-backend panicking-backend) | ||
| 248 | (error-backend warning-backend sync-backend)) | ||
| 249 | |||
| 250 | (goto-char (point-min)) | ||
| 251 | (flymake-goto-next-error) | ||
| 252 | (should (eq 'flymake-warning (face-at-point))) ; dolor | ||
| 253 | (flymake-goto-next-error) | ||
| 254 | (should (eq 'flymake-warning (face-at-point))) ; ut | ||
| 255 | (flymake-goto-next-error) | ||
| 256 | (should (eq 'flymake-error (face-at-point))) ; manha | ||
| 257 | (flymake-goto-next-error) | ||
| 258 | (should (eq 'flymake-warning (face-at-point))) ; Ut | ||
| 259 | (flymake-goto-next-error) | ||
| 260 | (should (eq 'flymake-note (face-at-point))) ; quis | ||
| 261 | (flymake-goto-next-error) | ||
| 262 | (should (eq 'flymake-warning (face-at-point))) ; ut | ||
| 263 | (flymake-goto-next-error) | ||
| 264 | (should (eq 'flymake-note (face-at-point))) ; commodo | ||
| 265 | (flymake-goto-next-error) | ||
| 266 | (should (eq 'flymake-warning (face-at-point))) ; dolor | ||
| 267 | (flymake-goto-next-error) | ||
| 268 | (should (eq 'flymake-error (face-at-point))) ; prognata | ||
| 269 | (should-error (flymake-goto-next-error nil nil t)))))) | ||
| 270 | |||
| 271 | (ert-deftest recurrent-backend () | ||
| 272 | "Test a backend that calls REPORT-FN multiple times" | ||
| 273 | (with-temp-buffer | ||
| 274 | (let (tick) | ||
| 275 | (cl-letf | ||
| 276 | (((symbol-function 'eager-backend) | ||
| 277 | (lambda (report-fn) | ||
| 278 | (funcall report-fn nil :explanation "very eager but no diagnostics") | ||
| 279 | (display-buffer (current-buffer)) | ||
| 280 | (run-with-timer | ||
| 281 | 0.5 nil | ||
| 282 | (lambda () | ||
| 283 | (flymake-tests--diagnose-words report-fn :warning '("consectetur")) | ||
| 284 | (setq tick t) | ||
| 285 | (run-with-timer | ||
| 286 | 0.5 nil | ||
| 287 | (lambda () | ||
| 288 | (flymake-tests--diagnose-words report-fn :error '("fugiat")) | ||
| 289 | (setq tick t)))))))) | ||
| 290 | (insert "Lorem ipsum dolor sit amet, consectetur adipiscing | ||
| 291 | elit, sed do eiusmod tempor incididunt ut labore et dolore | ||
| 292 | manha aliqua. Ut enim ad minim veniam, quis nostrud | ||
| 293 | exercitation ullamco laboris nisi ut aliquip ex ea commodo | ||
| 294 | consequat. Duis aute irure dolor in reprehenderit in | ||
| 295 | voluptate velit esse cillum dolore eu fugiat nulla | ||
| 296 | pariatur. Excepteur sint occaecat cupidatat non prognata | ||
| 297 | sunt in culpa qui officia deserunt mollit anim id est | ||
| 298 | laborum.") | ||
| 299 | (let ((flymake-diagnostic-functions | ||
| 300 | (list 'eager-backend)) | ||
| 301 | (flymake-wrap-around nil)) | ||
| 302 | (flymake-mode) | ||
| 303 | (flymake-tests--assert-set (flymake-running-backends) | ||
| 304 | (eager-backend) ()) | ||
| 305 | (cl-loop until tick repeat 4 do (sleep-for 0.2)) | ||
| 306 | (setq tick nil) | ||
| 307 | (goto-char (point-max)) | ||
| 308 | (flymake-goto-prev-error) | ||
| 309 | (should (eq 'flymake-warning (face-at-point))) ; consectetur | ||
| 310 | (should-error (flymake-goto-prev-error nil nil t)) | ||
| 311 | (cl-loop until tick repeat 4 do (sleep-for 0.2)) | ||
| 312 | (flymake-goto-next-error) | ||
| 313 | (should (eq 'flymake-error (face-at-point))) ; fugiat | ||
| 314 | (flymake-goto-prev-error) | ||
| 315 | (should (eq 'flymake-warning (face-at-point))) ; back at consectetur | ||
| 316 | (should-error (flymake-goto-prev-error nil nil t)) | ||
| 317 | ))))) | ||
| 77 | 318 | ||
| 78 | (provide 'flymake-tests) | 319 | (provide 'flymake-tests) |
| 79 | 320 | ||