;;; files.el --- tests for file handling.
-;; Copyright (C) 2012 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; Set to t if the local variable was set, `query' if the query was
;; triggered.
-(defvar files-test-result)
+(defvar files-test-result nil)
-(defvar files-test-safe-result)
+(defvar files-test-safe-result nil)
(put 'files-test-safe-result 'safe-local-variable 'booleanp)
(defun files-test-fun1 ()
(:all nil (eq files-test-result nil))
(:all maybe (eq files-test-result t)) ; This combination is ambiguous.
(maybe t (eq files-test-result 'query))
- (maybe nil (eq files-test-result 'query))
+ (maybe nil (eq files-test-result nil))
(maybe maybe (eq files-test-result 'query)))
;; Unsafe local variable value
(("files-test-result: t")
(defun file-test--do-local-variables-test (str test-settings)
(with-temp-buffer
(insert str)
+ (setq files-test-result nil
+ files-test-safe-result nil)
(let ((enable-local-variables (nth 0 test-settings))
(enable-local-eval (nth 1 test-settings))
- (files-test-result nil)
- (files-test-queried nil)
- (files-test-safe-result nil))
+ ;; Prevent any dir-locals file interfering with the tests.
+ (enable-dir-local-variables nil)
+ (files-test-queried nil))
(hack-local-variables)
(eval (nth 2 test-settings)))))
(should (file-test--do-local-variables-test str subtest))))))
(ad-disable-advice 'hack-local-variables-confirm 'around 'files-test)))
+(defvar files-test-bug-18141-file
+ (expand-file-name "data/files-bug18141.el.gz" (getenv "EMACS_TEST_DIRECTORY"))
+ "Test file for bug#18141.")
+
+(ert-deftest files-test-bug-18141 ()
+ "Test for http://debbugs.gnu.org/18141 ."
+ (skip-unless (executable-find "gzip"))
+ (let ((tempfile (make-temp-file "files-test-bug-18141" nil ".gz")))
+ (unwind-protect
+ (progn
+ (copy-file files-test-bug-18141-file tempfile t)
+ (with-current-buffer (find-file-noselect tempfile)
+ (set-buffer-modified-p t)
+ (save-buffer)
+ (should (eq buffer-file-coding-system 'iso-2022-7bit-unix))))
+ (delete-file tempfile))))
+
+
+;; Stop the above "Local Var..." confusing Emacs.
+\f
+
;;; files.el ends here