[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 86a4f30 07/3
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 86a4f30 07/39: Refactor flymake-tests.el in preparation for more tests |
Date: |
Mon, 2 Oct 2017 20:12:21 -0400 (EDT) |
branch: scratch/flymake-refactor-cleaner-for-emacs-26
commit 86a4f30c3c37d5d035a84ebe8c891f6a04d8a10d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Refactor flymake-tests.el in preparation for more tests
Introduce a slightly more generic fixture macro.
Also make flymake-tests.el friendlier to interactive runs, by not
killing buffers visited by the user.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): New helper from
flymake-tests--current-face. Don't kill file buffers already
being visited before the test starts.
(flymake-tests--with-flymake): New macro.
(flymake-tests--current-face): Delete.
(warning-predicate-rx-gcc, warning-predicate-function-gcc)
(warning-predicate-rx-perl, warning-predicate-function-perl):
Use flymake-test--with-flymake.
---
test/lisp/progmodes/flymake-tests.el | 68 +++++++++++++++++++++++++-----------
1 file changed, 47 insertions(+), 21 deletions(-)
diff --git a/test/lisp/progmodes/flymake-tests.el
b/test/lisp/progmodes/flymake-tests.el
index 338e8e0..c626aec 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -34,15 +34,23 @@
"Directory containing flymake test data.")
-;; Warning predicate
-(defun flymake-tests--current-face (file predicate)
- (let ((buffer (find-file-noselect
- (expand-file-name file flymake-tests-data-directory)))
- (process-environment (cons "LC_ALL=C" process-environment))
- (i 0))
+;;
+;;
+(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
+`flymake-proc-warning-predicate'."
+ (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))
+ (i 0))
(unwind-protect
(with-current-buffer buffer
- (setq-local flymake-proc-warning-predicate predicate)
+ (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
@@ -57,36 +65,54 @@
(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)))
- (flymake-goto-next-error)
- (face-at-point))
- (and buffer (let (kill-buffer-query-functions) (kill-buffer buffer))))))
+ (funcall fn))
+ (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))
(ert-deftest warning-predicate-rx-gcc ()
"Test GCC warning via regexp predicate."
(skip-unless (and (executable-find "gcc") (executable-find "make")))
- (should (eq 'flymake-warning
- (flymake-tests--current-face "test.c" "^[Ww]arning"))))
+ (flymake-tests--with-flymake
+ ("test.c" :severity-predicate "^[Ww]arning")
+ (flymake-goto-next-error)
+ (should (eq 'flymake-warning
+ (face-at-point)))))
(ert-deftest warning-predicate-function-gcc ()
"Test GCC warning via function predicate."
(skip-unless (and (executable-find "gcc") (executable-find "make")))
- (should (eq 'flymake-warning
- (flymake-tests--current-face "test.c"
- (lambda (msg) (string-match
"^[Ww]arning" msg))))))
+ (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)))))
(ert-deftest warning-predicate-rx-perl ()
"Test perl warning via regular expression predicate."
(skip-unless (executable-find "perl"))
- (should (eq 'flymake-warning
- (flymake-tests--current-face "test.pl" "^Scalar value"))))
+ (flymake-tests--with-flymake
+ ("test.pl" :severity-predicate "^Scalar value")
+ (flymake-goto-next-error)
+ (should (eq 'flymake-warning
+ (face-at-point)))))
(ert-deftest warning-predicate-function-perl ()
"Test perl warning via function predicate."
(skip-unless (executable-find "perl"))
- (should (eq 'flymake-warning
- (flymake-tests--current-face
- "test.pl"
- (lambda (msg) (string-match "^Scalar value" msg))))))
+ (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)))))
(provide 'flymake-tests)
- [Emacs-diffs] branch scratch/flymake-refactor-cleaner-for-emacs-26 created (now b80d29d), João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 427bb8d 02/39: Flymake provides flymake-report re-entry point for backends, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b17ec76 10/39: Flymake warning face easier to distinguish, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 79867d3 06/39: Allow running flymake-tests.el from interactive sessions, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 555bea3 11/39: Protect against timer triggers when no flymake-mode, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 da45044 09/39: Flymake's flymake-proc.el parses column numbers from gcc/javac errors, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 9357120 13/39: Echo Flymake error messages when navigating errors interactively, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 86a4f30 07/39: Refactor flymake-tests.el in preparation for more tests,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 8f50239 12/39: Add a new Flymake test for multiple errors and warnings, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4f7d568 14/39: Flymake checks file names before considering diagnostics, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 0a4e420 16/39: Protect Flymake's eager checks against commands like fill-paragraph, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c8004c6 03/39: Completely rewrite Flymake's subprocess output processing, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b48161 21/39: Tweak Flymake commands flymake-goto-[next/prev]-error, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2dd9e04 24/39: Add interactive flymake-start function, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 a458e1a 26/39: Treat flymake errors as just another type of diagnostic, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4ae24d7 20/39: Flymake's flymake-proc.el backend slightly easier to debug, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4d6d56d 27/39: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 ef67227 29/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/02