[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mmm-mode f21c8f35ec 1/9: Make the tests work in batch m
From: |
ELPA Syncer |
Subject: |
[elpa] externals/mmm-mode f21c8f35ec 1/9: Make the tests work in batch mode |
Date: |
Thu, 27 Oct 2022 19:57:53 -0400 (EDT) |
branch: externals/mmm-mode
commit f21c8f35ec7a0af78b4faf3baa592fbe540c5b53
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Make the tests work in batch mode
Add the test macro mmm-with-global-font-lock and use it.
Both font-lock-mode and mmm-mode wont start unless noninteractive is
nil and the buffer names start with a non-blank character.
Global minor modes add functions to some hooks, do that locally in
mmm-with-global-font-lock.
---
tests/highlighting.el | 19 ++++++++++++------
tests/html-erb.el | 6 ++++--
tests/mmm-test-util.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/tests/highlighting.el b/tests/highlighting.el
index b7519a610b..e03d25eb1b 100644
--- a/tests/highlighting.el
+++ b/tests/highlighting.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2013-2014, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2014, 2020, 2022 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
@@ -20,6 +20,8 @@
;;; Code:
(require 'ert-x)
+(require 'mmm-test-util)
+(require 'mmm-mode)
(defvar foo-mode-keywords
`((,(concat "\\b"
@@ -31,6 +33,7 @@
(setq font-lock-defaults '(foo-mode-keywords t t)))
(ert-deftest mmm-font-lock-without-font-lock-syntax-table ()
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
@@ -45,12 +48,13 @@
(search-forward "fo" nil nil 2)
(should (eq (get-text-property (point) 'face) font-lock-keyword-face))
(search-forward "ba")
- (should (eq (get-text-property (point) 'face) font-lock-keyword-face)))))
+ (should (eq (get-text-property (point) 'face)
font-lock-keyword-face))))))
(define-derived-mode foo2-mode fundamental-mode ""
(setq font-lock-defaults '(foo-mode-keywords t t ((?_ . "w")))))
(ert-deftest mmm-font-lock-with-font-lock-syntax-table ()
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
@@ -60,12 +64,13 @@
(mmm-mode-on)
(mmm-ify-by-regexp 'foo2-mode "// " 0 "\\'" 0 nil)
(font-lock-fontify-region (point-min) (point-max))
- (should-not (next-single-property-change (point-min) 'face)))))
+ (should-not (next-single-property-change (point-min) 'face))))))
(define-derived-mode foo3-mode fundamental-mode ""
(setq font-lock-defaults '(foo-mode-keywords nil t ((?_ . "w")))))
(ert-deftest mmm-syntax-propertize-function-preserves-current-syntax-table ()
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle)
@@ -79,9 +84,10 @@
(let ((pt (next-single-property-change (point-min) 'face)))
(should pt)
(goto-char pt)
- (should (looking-at "foo\\'"))))))
+ (should (looking-at "foo\\'")))))))
(ert-deftest mmm-fontify-region-list-ignores-outside-for-syntactic-ff-tion ()
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle
@@ -96,9 +102,10 @@
(font-lock-fontify-region (point-min) (point-max))
(search-backward "var")
(should (eq 'font-lock-keyword-face
- (get-text-property (point) 'face))))))
+ (get-text-property (point) 'face)))))))
(ert-deftest mmm-fontify-region-list-carries-string-after-subregion ()
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let (mmm-mode-ext-classes-alist
mmm-parse-when-idle
@@ -113,4 +120,4 @@
(should (null (get-text-property (point) 'face)))
(search-forward "bar")
(should (eq 'font-lock-string-face
- (get-text-property (point) 'face))))))
+ (get-text-property (point) 'face)))))))
diff --git a/tests/html-erb.el b/tests/html-erb.el
index 25188e597f..874cf7fde4 100644
--- a/tests/html-erb.el
+++ b/tests/html-erb.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2013, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2020, 2022 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
@@ -22,6 +22,7 @@
(require 'ert)
(require 'ert-x)
(require 'mmm-erb)
+(require 'mmm-test-util)
(defvar mmm-erb-text
"<%= foo do %>
@@ -42,6 +43,7 @@
(setq body (nthcdr 2 body)))
`(ert-deftest ,(intern (format "mmm-erb-%s" name)) ()
:expected-result ,(or expected-result :passed)
+ (mmm-with-global-font-lock
(ert-with-test-buffer nil
(let ((buffer-file-name "foo.html.erb")
(mmm-global-mode 'maybe)
@@ -51,7 +53,7 @@
(html-erb-mode)
(mmm-mode-on-maybe)
(should mmm-mode)
- ,@body)))))
+ ,@body))))))
(put 'mmm-erb-deftest 'lisp-indent-function 'defun)
diff --git a/tests/mmm-test-util.el b/tests/mmm-test-util.el
new file mode 100644
index 0000000000..2518a6c907
--- /dev/null
+++ b/tests/mmm-test-util.el
@@ -0,0 +1,53 @@
+;;; mmm-test-util.el --- Test helpers for mmm-mode tests
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Ola Nilsson <ola.nilsson@gmail.com>
+
+;; {{{ GPL
+
+;; This program 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.
+
+;; This program 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
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
+;;}}}
+
+;;; Commentary:
+
+;; This file contains help functions and macros for mmm-mode tests
+
+;;; Code:
+
+(require 'font-core)
+
+(defmacro mmm-with-global-font-lock (&rest body)
+ "Fake active `global-font-lock-mode' for BODY."
+ ;; This is a hack.
+ ;; Locally bind `noninteractive' to nil and set upp hooks as
+ ;; `global-font-lock-mode' would have. Assumes
+ ;; global-font-lock-mode has been avaluated so all the required
+ ;; global-font-lock-mode-X exist.
+ (declare (indent 'defun))
+ `(let ((after-change-major-mode-hook after-change-major-mode-hook)
+ (find-file-hook find-file-hook)
+ (change-major-mode-hook change-major-mode-hook)
+ noninteractive)
+ ;; the enable part of the global minor mode
+ (add-hook 'after-change-major-mode-hook
+ #'global-font-lock-mode-enable-in-buffers)
+ (add-hook 'find-file-hook #'global-font-lock-mode-check-buffers)
+ (add-hook 'change-major-mode-hook #'global-font-lock-mode-cmhh)
+ ,@body))
+
+(provide 'mmm-test-util)
+;;; mmm-test-util.el ends here
- [elpa] externals/mmm-mode updated (328b6a9c67 -> 3c2071347a), ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 921a7d917b 3/9: Remove Automake and spec files, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 9a47119a02 5/9: Add mmm-autoload-class-private-p and use it, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 96d832f61a 2/9: Add Makefile to compile and test test code, and build docs, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 3c2071347a 9/9: Merge pull request #133 from snogge/batch-tests, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode f21c8f35ec 1/9: Make the tests work in batch mode,
ELPA Syncer <=
- [elpa] externals/mmm-mode b18a363679 4/9: Include README, README.Mason and FAQ in elpa package, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 122bcd6d0c 6/9: Drop rx-let, use mmm-add-group for the sh-here-doc classes, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode 5c985be5cb 7/9: Add GitHub Workflow for testing, ELPA Syncer, 2022/10/27
- [elpa] externals/mmm-mode d1c85e5e2c 8/9: Release 0.5.9, ELPA Syncer, 2022/10/27