[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-t
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-tests.el in preparation for more tests |
Date: |
Sun, 1 Oct 2017 12:40:46 -0400 (EDT) |
branch: scratch/flymake-refactor
commit f3b8a72c5023052bbd8db568d97b697b7cfe98c3
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.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): New helper from
flymake-tests--current-face.
(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 | 55 +++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 16 deletions(-)
diff --git a/test/lisp/progmodes/flymake-tests.el
b/test/lisp/progmodes/flymake-tests.el
index d17f78e..cbef584 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -34,8 +34,14 @@
"Directory containing flymake test data.")
-;; Warning predicate
-(defun flymake-tests--current-face (file predicate)
+;;
+;;
+(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)))
@@ -43,7 +49,8 @@
(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
@@ -58,38 +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))
+ (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] scratch/flymake-refactor 2693054 14/52: Flymake faces are not just for "lines" anymore, (continued)
- [Emacs-diffs] scratch/flymake-refactor 2693054 14/52: Flymake faces are not just for "lines" anymore, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 991c88f 18/52: flymake-warning face easier to distinguish from flymake-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 12aa247 19/52: Protect against timer triggers when no flymake-mode, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 740572e 05/52: Completely rewrite flymake's subprocess output processing, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 14db516 22/52: flymake-ui.el checks file names before considering diagnostics, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 61ba20b 21/52: Echo flymake error messages when navigating errors interactively, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor b2c4135 15/52: Clarify logic around flymake-diagnostic-types-alist, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor bac7512 12/52: New flymake-diagnostic-types-alist and more cleanup, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 7140018 25/52: Protect flymake-ui against commands like fill-paragraph, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor d3168cf 09/52: Make lisp/progmodes/flymake-ui.el some 150 lines lighter, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-tests.el in preparation for more tests,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor 593d4303 23/52: Add a new flymake test for multiple errors and warnings, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor d68448f 26/52: More cleanup before advancing to backend redesign, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 245114e 33/52: Fix autoload conflict between flymake.el and flymake-ui.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 4fea8a9 30/52: Allow filtering in flymake-goto-[next/prev]-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 192cb7f 24/52: flymake-ui.el highlights GCC notes detected by flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 879dcef 29/52: Misc cleanup in flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 820b460 35/52: Add interactive flymake-start function, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 8e42a5d 31/52: Cleanup some flymake-ui.el internals, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor e1b913f 36/52: Re-implement wraparound for flymake-goto-next-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 3dfe11c 28/52: Simplify flymake logging and erroring., João Távora, 2017/10/01