From 4874f0bbac9362250d4ea0d04ec6c46af4d2fa0b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 Sep 2015 22:13:31 -0700 Subject: [PATCH] =?utf8?q?Support=20automated=20=E2=80=98make=20check?= =?utf8?q?=E2=80=99=20in=20non-C=20locale?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This lets the builder optionally test Emacs behavior in other locales. The C locale is still the default for tests. * test/automated/Makefile.in (TEST_LOCALE): New macro. (emacs): Use it. * test/automated/flymake-tests.el (flymake-tests--current-face): Use C locale for subprocesses so that tests behave as expected. * test/automated/python-tests.el: (python-shell-prompt-validate-regexps-1) (python-shell-prompt-validate-regexps-2) (python-shell-prompt-validate-regexps-3) (python-shell-prompt-validate-regexps-4) (python-shell-prompt-validate-regexps-5) (python-shell-prompt-validate-regexps-6) (python-shell-prompt-set-calculated-regexps-1): Adjust expected output to match locale. * test/automated/tildify-tests.el (tildify-test--test) (tildify-space-test--test, tildify-space-undo-test--test): This test assumes UTF-8 encoding. --- test/automated/Makefile.in | 8 +++++++- test/automated/flymake-tests.el | 1 + test/automated/python-tests.el | 21 ++++++++++++++------- test/automated/tildify-tests.el | 3 +++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/test/automated/Makefile.in b/test/automated/Makefile.in index 174b3b6dffe..59a88663e2a 100644 --- a/test/automated/Makefile.in +++ b/test/automated/Makefile.in @@ -52,9 +52,15 @@ unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS ## To run tests under a debugger, set this to eg: "gdb --args". GDB = +# The locale to run tests under. Tests should work if this is set to +# any supported locale. Use the C locale by default, as it should be +# supported everywhere. +TEST_LOCALE = C + # The actual Emacs command run in the targets below. # Prevent any setting of EMACSLOADPATH in user environment causing problems. -emacs = EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) $(GDB) "$(EMACS)" $(EMACSOPT) +emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) EMACS_TEST_DIRECTORY=$(srcdir) \ + $(GDB) "$(EMACS)" $(EMACSOPT) .PHONY: all check diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el index 23dbb3d010c..a77c31638a5 100644 --- a/test/automated/flymake-tests.el +++ b/test/automated/flymake-tests.el @@ -34,6 +34,7 @@ (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)) (unwind-protect (with-current-buffer buffer diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 219f99eed62..d9b4c3e1b06 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2920,7 +2920,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-input-regexps'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-input-regexps'"))))) (ert-deftest python-shell-prompt-validate-regexps-2 () "Check `python-shell-prompt-output-regexps' are validated." @@ -2929,7 +2930,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-output-regexps'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-output-regexps'"))))) (ert-deftest python-shell-prompt-validate-regexps-3 () "Check `python-shell-prompt-regexp' is validated." @@ -2938,7 +2940,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-regexp'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-regexp'"))))) (ert-deftest python-shell-prompt-validate-regexps-4 () "Check `python-shell-prompt-block-regexp' is validated." @@ -2947,7 +2950,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-block-regexp'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-block-regexp'"))))) (ert-deftest python-shell-prompt-validate-regexps-5 () "Check `python-shell-prompt-pdb-regexp' is validated." @@ -2956,7 +2960,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-pdb-regexp'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-pdb-regexp'"))))) (ert-deftest python-shell-prompt-validate-regexps-6 () "Check `python-shell-prompt-output-regexp' is validated." @@ -2965,7 +2970,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-output-regexp'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-output-regexp'"))))) (ert-deftest python-shell-prompt-validate-regexps-7 () "Check default regexps are valid." @@ -2982,7 +2988,8 @@ and `python-shell-interpreter-args' in the new shell buffer." :type 'user-error))) (should (string= (cadr error-data) - "Invalid regexp \\( in `python-shell-prompt-output-regexp'")))) + (format-message + "Invalid regexp \\( in `python-shell-prompt-output-regexp'"))))) (ert-deftest python-shell-prompt-set-calculated-regexps-2 () "Check `python-shell-prompt-input-regexps' are set." diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index b53f58c279e..788abe7f731 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -55,6 +55,7 @@ If IS-XML is non-nil,
 tag is not treated specially."
 INPUT is the initial content of the buffer and EXPECTED is expected result
 after `tildify-buffer' is run."
   (with-temp-buffer
+    (setq-local buffer-file-coding-system 'utf-8)
     (dolist (mode modes)
       (erase-buffer)
       (funcall mode)
@@ -187,6 +188,7 @@ The function must terminate as soon as callback returns nil."
 
 (defun tildify-space-test--test (modes nbsp env-open &optional set-space-string)
   (with-temp-buffer
+    (setq-local buffer-file-coding-system 'utf-8)
     (dolist (mode modes)
       (funcall mode)
       (when set-space-string
@@ -226,6 +228,7 @@ The function must terminate as soon as callback returns nil."
 (defun tildify-space-undo-test--test
     (modes nbsp env-open &optional set-space-string)
   (with-temp-buffer
+    (setq-local buffer-file-coding-system 'utf-8)
     (dolist (mode modes)
       (funcall mode)
       (when set-space-string
-- 
2.39.2