diff options
author | Tom Tromey <tromey@redhat.com> | 2013-07-12 18:44:13 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2013-07-12 18:44:13 -0600 |
commit | b34a529f177a6ea32da5cb1254f91bf9d71838db (patch) | |
tree | 477131abc15d3107b30b635223d87a22550b480b /test | |
parent | e6f63071a3f7721f55220514b6d9a8ee8c1232d8 (diff) | |
parent | 5e301d7651c0691bb2bc7f3fbe711fdbe26ac471 (diff) | |
download | emacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.tar.gz |
Merge from trunk
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 67 | ||||
-rw-r--r-- | test/automated/add-log-tests.el | 1 | ||||
-rw-r--r-- | test/automated/advice-tests.el | 2 | ||||
-rw-r--r-- | test/automated/cl-lib.el | 198 | ||||
-rw-r--r-- | test/automated/decoder-tests.el | 5 | ||||
-rw-r--r-- | test/automated/ert-tests.el | 171 | ||||
-rw-r--r-- | test/automated/file-notify-tests.el | 151 | ||||
-rw-r--r-- | test/automated/files.el | 3 | ||||
-rw-r--r-- | test/automated/flymake-tests.el | 3 | ||||
-rw-r--r-- | test/automated/icalendar-tests.el | 3 | ||||
-rw-r--r-- | test/automated/imenu-test.el | 1 | ||||
-rw-r--r-- | test/automated/inotify-test.el | 5 | ||||
-rwxr-xr-x | test/automated/package-test.el | 7 | ||||
-rwxr-xr-x | test/automated/package-x-test.el | 1 | ||||
-rw-r--r-- | test/automated/python-tests.el | 5 | ||||
-rw-r--r-- | test/automated/ruby-mode-tests.el | 24 | ||||
-rw-r--r-- | test/automated/undo-tests.el | 26 | ||||
-rw-r--r-- | test/automated/xml-parse-tests.el | 1 |
18 files changed, 411 insertions, 263 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index aded5473304..d3d8db6b501 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,68 @@ +2013-07-11 Glenn Morris <rgm@gnu.org> + + * automated/ert-tests.el: Require cl-lib at runtime too. + (ert-test-special-operator-p): Use cl-gensym rather than ert-- version. + (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*) + (ert-test-set-functions, ert-test-gensym) + (ert-test-coerce-to-vector, ert-test-string-position) + (ert-test-mismatch): Remove tests. + * automated/cl-lib.el: New, split from ert-tests.el. + + * automated/ruby-mode-tests.el (ruby-deftest-move-to-block): + Goto point-min. + (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two) + (ruby-move-to-block-skips-percent-literal) + (ruby-move-to-block-skips-heredoc) + (ruby-move-to-block-moves-from-else-to-if) + (ruby-beginning-of-defun-does-not-fold-case) + (ruby-end-of-defun-skips-to-next-line-after-the-method): + Replace goto-line with forward-line/goto-char. + (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer. + + * automated/package-test.el (makeinfo-buffer): Autoload. + (compilation-in-progress, tar-parse-info, tar-header-name): Declare. + (package-test-install-texinfo): Don't require makeinfo. + + * automated/files.el: Stop "local variables" confusion. + + * automated/flymake-tests.el (flymake-tests): Remove unused group. + + * automated/icalendar-tests.el (icalendar-tests--do-test-cycle): + Use with-current-buffer. + + * automated/undo-tests.el (undo-test-buffer-modified) + (undo-test-file-modified): New tests. + +2013-07-09 Michael Albinus <michael.albinus@gmx.de> + + * automated/file-notify-tests.el (file-notify-test00-availability): + Set :expected-result. + (file-notify-test01-add-watch, file-notify-test01-add-watch-remote) + (file-notify-test02-events, file-notify-test02-events-remote) + (file-notify-test03-autorevert, file-notify-test03-autorevert-remote): + Skip when `file-notify-support' is nil. (Bug#14823) + +2013-07-09 Glenn Morris <rgm@gnu.org> + + * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch): + Declare. + (inotify-file-watch-simple): Silence compiler. + + * automated/python-tests.el (python-indent-block-enders): + Make it actually test something. + + * automated/package-x-test.el: Require package-test when compiling. + + * automated/add-log-tests.el, automated/advice-tests.el: + * automated/imenu-test.el, automated/package-x-test.el: + * automated/python-tests.el, automated/ruby-mode-tests.el: + * automated/xml-parse-tests.el: Explictly require ert. + +2013-07-08 Kenichi Handa <handa@gnu.org> + + * automated/decoder-tests.el (decoder-tests-prefer-utf-8-read): + Use with-ccoding-priority to avoid side-effect (Bug#14781). + 2013-07-05 Michael Albinus <michael.albinus@gmx.de> * automated/file-notify-tests.el @@ -71,7 +136,7 @@ Use it to create separate tests for each element, so we run them all rather than stopping at the first error. -2013-06-24 Glenn Morris <rgm@fencepost.gnu.org> +2013-06-24 Glenn Morris <rgm@gnu.org> * automated/occur-tests.el (occur-tests): Update for 2013-05-29 change to occur header line. diff --git a/test/automated/add-log-tests.el b/test/automated/add-log-tests.el index f6e803cd317..bd073016505 100644 --- a/test/automated/add-log-tests.el +++ b/test/automated/add-log-tests.el @@ -22,6 +22,7 @@ ;;; Code: +(require 'ert) (require 'add-log) (defmacro add-log-current-defun-deftest (name doc major-mode diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index 8beaea64cd9..69c15e34ed0 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el @@ -21,6 +21,8 @@ ;;; Code: +(require 'ert) + (ert-deftest advice-tests-nadvice () "Test nadvice code." (defun sm-test1 (x) (+ x 4)) diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el new file mode 100644 index 00000000000..3a339e01734 --- /dev/null +++ b/test/automated/cl-lib.el @@ -0,0 +1,198 @@ +;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; 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 `http://www.gnu.org/licenses/'. + +;;; Commentary: + +;; Extracted from ert-tests.el, back when ert used to reimplement some +;; cl functions. + +;;; Code: + +(require 'cl-lib) +(require 'ert) + +(ert-deftest cl-lib-test-remprop () + (let ((x (cl-gensym))) + (should (equal (symbol-plist x) '())) + ;; Remove nonexistent property on empty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())) + (put x 'a 1) + (should (equal (symbol-plist x) '(a 1))) + ;; Remove nonexistent property on nonempty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '(a 1))) + (put x 'b 2) + (put x 'c 3) + (put x 'd 4) + (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) + ;; Remove property that is neither first nor last. + (cl-remprop x 'c) + (should (equal (symbol-plist x) '(a 1 b 2 d 4))) + ;; Remove last property from a plist of length >1. + (cl-remprop x 'd) + (should (equal (symbol-plist x) '(a 1 b 2))) + ;; Remove first property from a plist of length >1. + (cl-remprop x 'a) + (should (equal (symbol-plist x) '(b 2))) + ;; Remove property when there is only one. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())))) + +(ert-deftest cl-lib-test-remove-if-not () + (let ((list (list 'a 'b 'c 'd)) + (i 0)) + (let ((result (cl-remove-if-not (lambda (x) + (should (eql x (nth i list))) + (cl-incf i) + (member i '(2 3))) + list))) + (should (equal i 4)) + (should (equal result '(b c))) + (should (equal list '(a b c d))))) + (should (equal '() + (cl-remove-if-not (lambda (_x) (should nil)) '())))) + +(ert-deftest cl-lib-test-remove () + (let ((list (list 'a 'b 'c 'd)) + (key-index 0) + (test-index 0)) + (let ((result + (cl-remove 'foo list + :key (lambda (x) + (should (eql x (nth key-index list))) + (prog1 + (list key-index x) + (cl-incf key-index))) + :test + (lambda (a b) + (should (eql a 'foo)) + (should (equal b (list test-index + (nth test-index list)))) + (cl-incf test-index) + (member test-index '(2 3)))))) + (should (equal key-index 4)) + (should (equal test-index 4)) + (should (equal result '(a d))) + (should (equal list '(a b c d))))) + (let ((x (cons nil nil)) + (y (cons nil nil))) + (should (equal (cl-remove x (list x y)) + ;; or (list x), since we use `equal' -- the + ;; important thing is that only one element got + ;; removed, this proves that the default test is + ;; `eql', not `equal' + (list y))))) + + +(ert-deftest cl-lib-test-set-functions () + (let ((c1 (cons nil nil)) + (c2 (cons nil nil)) + (sym (make-symbol "a"))) + (let ((e '()) + (a (list 'a 'b sym nil "" "x" c1 c2)) + (b (list c1 'y 'b sym 'x))) + (should (equal (cl-set-difference e e) e)) + (should (equal (cl-set-difference a e) a)) + (should (equal (cl-set-difference e a) e)) + (should (equal (cl-set-difference a a) e)) + (should (equal (cl-set-difference b e) b)) + (should (equal (cl-set-difference e b) e)) + (should (equal (cl-set-difference b b) e)) + ;; Note: this test (and others) is sensitive to the order of the + ;; result, which is not documented. + (should (equal (cl-set-difference a b) (list c2 "x" "" nil 'a))) + (should (equal (cl-set-difference b a) (list 'x 'y))) + + ;; We aren't testing whether this is really using `eq' rather than `eql'. + (should (equal (cl-set-difference e e :test 'eq) e)) + (should (equal (cl-set-difference a e :test 'eq) a)) + (should (equal (cl-set-difference e a :test 'eq) e)) + (should (equal (cl-set-difference a a :test 'eq) e)) + (should (equal (cl-set-difference b e :test 'eq) b)) + (should (equal (cl-set-difference e b :test 'eq) e)) + (should (equal (cl-set-difference b b :test 'eq) e)) + (should (equal (cl-set-difference a b :test 'eq) (list c2 "x" "" nil 'a))) + (should (equal (cl-set-difference b a :test 'eq) (list 'x 'y))) + + (should (equal (cl-union e e) e)) + (should (equal (cl-union a e) a)) + (should (equal (cl-union e a) a)) + (should (equal (cl-union a a) a)) + (should (equal (cl-union b e) b)) + (should (equal (cl-union e b) b)) + (should (equal (cl-union b b) b)) + (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-intersection e e) e)) + (should (equal (cl-intersection a e) e)) + (should (equal (cl-intersection e a) e)) + (should (equal (cl-intersection a a) a)) + (should (equal (cl-intersection b e) e)) + (should (equal (cl-intersection e b) e)) + (should (equal (cl-intersection b b) b)) + (should (equal (cl-intersection a b) (list sym 'b c1))) + (should (equal (cl-intersection b a) (list sym 'b c1)))))) + +(ert-deftest cl-lib-test-gensym () + ;; Since the expansion of `should' calls `cl-gensym' and thus has a + ;; side-effect on `cl--gensym-counter', we have to make sure all + ;; macros in our test body are expanded before we rebind + ;; `cl--gensym-counter' and run the body. Otherwise, the test would + ;; fail if run interpreted. + (let ((body (byte-compile + '(lambda () + (should (equal (symbol-name (cl-gensym)) "G0")) + (should (equal (symbol-name (cl-gensym)) "G1")) + (should (equal (symbol-name (cl-gensym)) "G2")) + (should (equal (symbol-name (cl-gensym "foo")) "foo3")) + (should (equal (symbol-name (cl-gensym "bar")) "bar4")) + (should (equal cl--gensym-counter 5)))))) + (let ((cl--gensym-counter 0)) + (funcall body)))) + +(ert-deftest cl-lib-test-coerce-to-vector () + (let* ((a (vector)) + (b (vector 1 a 3)) + (c (list)) + (d (list b a))) + (should (eql (cl-coerce a 'vector) a)) + (should (eql (cl-coerce b 'vector) b)) + (should (equal (cl-coerce c 'vector) (vector))) + (should (equal (cl-coerce d 'vector) (vector b a))))) + +(ert-deftest cl-lib-test-string-position () + (should (eql (cl-position ?x "") nil)) + (should (eql (cl-position ?a "abc") 0)) + (should (eql (cl-position ?b "abc") 1)) + (should (eql (cl-position ?c "abc") 2)) + (should (eql (cl-position ?d "abc") nil)) + (should (eql (cl-position ?A "abc") nil))) + +(ert-deftest cl-lib-test-mismatch () + (should (eql (cl-mismatch "" "") nil)) + (should (eql (cl-mismatch "" "a") 0)) + (should (eql (cl-mismatch "a" "a") nil)) + (should (eql (cl-mismatch "ab" "a") 1)) + (should (eql (cl-mismatch "Aa" "aA") 0)) + (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) + +;;; cl-lib.el ends here diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el index e1b05faf3c0..2e99fd7f115 100644 --- a/test/automated/decoder-tests.el +++ b/test/automated/decoder-tests.el @@ -213,10 +213,9 @@ ;; PREFER is non-nil, prefer that coding system before reading. (defun decoder-tests-prefer-utf-8-read (file detect prefer) - (if prefer - (prefer-coding-system prefer)) (with-temp-buffer - (insert-file-contents file) + (with-coding-priority (if prefer (list prefer)) + (insert-file-contents file)) (if (eq buffer-file-coding-system detect) nil (format "Invalid detection: %s" buffer-file-coding-system)))) diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el index 0c3c3692c1d..36864377ec9 100644 --- a/test/automated/ert-tests.el +++ b/test/automated/ert-tests.el @@ -26,11 +26,9 @@ ;;; Code: -(eval-when-compile - (require 'cl-lib)) +(require 'cl-lib) (require 'ert) - ;;; Self-test that doesn't rely on ERT, for bootstrapping. ;; This is used to test that bodies actually run. @@ -578,7 +576,7 @@ This macro is used to test if macroexpansion in `should' works." (should (ert--special-operator-p 'if)) (should-not (ert--special-operator-p 'car)) (should-not (ert--special-operator-p 'ert--special-operator-p)) - (let ((b (ert--gensym))) + (let ((b (cl-gensym))) (should-not (ert--special-operator-p b)) (fset b 'if) (should (ert--special-operator-p b)))) @@ -626,171 +624,6 @@ This macro is used to test if macroexpansion in `should' works." :explanation nil) )))))) -(ert-deftest ert-test-remprop () - (let ((x (ert--gensym))) - (should (equal (symbol-plist x) '())) - ;; Remove nonexistent property on empty plist. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '())) - (put x 'a 1) - (should (equal (symbol-plist x) '(a 1))) - ;; Remove nonexistent property on nonempty plist. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '(a 1))) - (put x 'b 2) - (put x 'c 3) - (put x 'd 4) - (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) - ;; Remove property that is neither first nor last. - (ert--remprop x 'c) - (should (equal (symbol-plist x) '(a 1 b 2 d 4))) - ;; Remove last property from a plist of length >1. - (ert--remprop x 'd) - (should (equal (symbol-plist x) '(a 1 b 2))) - ;; Remove first property from a plist of length >1. - (ert--remprop x 'a) - (should (equal (symbol-plist x) '(b 2))) - ;; Remove property when there is only one. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '())))) - -(ert-deftest ert-test-remove-if-not () - (let ((list (list 'a 'b 'c 'd)) - (i 0)) - (let ((result (ert--remove-if-not (lambda (x) - (should (eql x (nth i list))) - (cl-incf i) - (member i '(2 3))) - list))) - (should (equal i 4)) - (should (equal result '(b c))) - (should (equal list '(a b c d))))) - (should (equal '() - (ert--remove-if-not (lambda (_x) (should nil)) '())))) - -(ert-deftest ert-test-remove* () - (let ((list (list 'a 'b 'c 'd)) - (key-index 0) - (test-index 0)) - (let ((result - (ert--remove* 'foo list - :key (lambda (x) - (should (eql x (nth key-index list))) - (prog1 - (list key-index x) - (cl-incf key-index))) - :test - (lambda (a b) - (should (eql a 'foo)) - (should (equal b (list test-index - (nth test-index list)))) - (cl-incf test-index) - (member test-index '(2 3)))))) - (should (equal key-index 4)) - (should (equal test-index 4)) - (should (equal result '(a d))) - (should (equal list '(a b c d))))) - (let ((x (cons nil nil)) - (y (cons nil nil))) - (should (equal (ert--remove* x (list x y)) - ;; or (list x), since we use `equal' -- the - ;; important thing is that only one element got - ;; removed, this proves that the default test is - ;; `eql', not `equal' - (list y))))) - - -(ert-deftest ert-test-set-functions () - (let ((c1 (cons nil nil)) - (c2 (cons nil nil)) - (sym (make-symbol "a"))) - (let ((e '()) - (a (list 'a 'b sym nil "" "x" c1 c2)) - (b (list c1 'y 'b sym 'x))) - (should (equal (ert--set-difference e e) e)) - (should (equal (ert--set-difference a e) a)) - (should (equal (ert--set-difference e a) e)) - (should (equal (ert--set-difference a a) e)) - (should (equal (ert--set-difference b e) b)) - (should (equal (ert--set-difference e b) e)) - (should (equal (ert--set-difference b b) e)) - (should (equal (ert--set-difference a b) (list 'a nil "" "x" c2))) - (should (equal (ert--set-difference b a) (list 'y 'x))) - - ;; We aren't testing whether this is really using `eq' rather than `eql'. - (should (equal (ert--set-difference-eq e e) e)) - (should (equal (ert--set-difference-eq a e) a)) - (should (equal (ert--set-difference-eq e a) e)) - (should (equal (ert--set-difference-eq a a) e)) - (should (equal (ert--set-difference-eq b e) b)) - (should (equal (ert--set-difference-eq e b) e)) - (should (equal (ert--set-difference-eq b b) e)) - (should (equal (ert--set-difference-eq a b) (list 'a nil "" "x" c2))) - (should (equal (ert--set-difference-eq b a) (list 'y 'x))) - - (should (equal (ert--union e e) e)) - (should (equal (ert--union a e) a)) - (should (equal (ert--union e a) a)) - (should (equal (ert--union a a) a)) - (should (equal (ert--union b e) b)) - (should (equal (ert--union e b) b)) - (should (equal (ert--union b b) b)) - (should (equal (ert--union a b) (list 'a 'b sym nil "" "x" c1 c2 'y 'x))) - (should (equal (ert--union b a) (list c1 'y 'b sym 'x 'a nil "" "x" c2))) - - (should (equal (ert--intersection e e) e)) - (should (equal (ert--intersection a e) e)) - (should (equal (ert--intersection e a) e)) - (should (equal (ert--intersection a a) a)) - (should (equal (ert--intersection b e) e)) - (should (equal (ert--intersection e b) e)) - (should (equal (ert--intersection b b) b)) - (should (equal (ert--intersection a b) (list 'b sym c1))) - (should (equal (ert--intersection b a) (list c1 'b sym)))))) - -(ert-deftest ert-test-gensym () - ;; Since the expansion of `should' calls `ert--gensym' and thus has a - ;; side-effect on `ert--gensym-counter', we have to make sure all - ;; macros in our test body are expanded before we rebind - ;; `ert--gensym-counter' and run the body. Otherwise, the test would - ;; fail if run interpreted. - (let ((body (byte-compile - '(lambda () - (should (equal (symbol-name (ert--gensym)) "G0")) - (should (equal (symbol-name (ert--gensym)) "G1")) - (should (equal (symbol-name (ert--gensym)) "G2")) - (should (equal (symbol-name (ert--gensym "foo")) "foo3")) - (should (equal (symbol-name (ert--gensym "bar")) "bar4")) - (should (equal ert--gensym-counter 5)))))) - (let ((ert--gensym-counter 0)) - (funcall body)))) - -(ert-deftest ert-test-coerce-to-vector () - (let* ((a (vector)) - (b (vector 1 a 3)) - (c (list)) - (d (list b a))) - (should (eql (ert--coerce-to-vector a) a)) - (should (eql (ert--coerce-to-vector b) b)) - (should (equal (ert--coerce-to-vector c) (vector))) - (should (equal (ert--coerce-to-vector d) (vector b a))))) - -(ert-deftest ert-test-string-position () - (should (eql (ert--string-position ?x "") nil)) - (should (eql (ert--string-position ?a "abc") 0)) - (should (eql (ert--string-position ?b "abc") 1)) - (should (eql (ert--string-position ?c "abc") 2)) - (should (eql (ert--string-position ?d "abc") nil)) - (should (eql (ert--string-position ?A "abc") nil))) - -(ert-deftest ert-test-mismatch () - (should (eql (ert--mismatch "" "") nil)) - (should (eql (ert--mismatch "" "a") 0)) - (should (eql (ert--mismatch "a" "a") nil)) - (should (eql (ert--mismatch "ab" "a") 1)) - (should (eql (ert--mismatch "Aa" "aA") 0)) - (should (eql (ert--mismatch '(a b c) '(a b d)) 2))) - (ert-deftest ert-test-string-first-line () (should (equal (ert--string-first-line "") "")) (should (equal (ert--string-first-line "abc") "abc")) diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 8fcfbe548fc..0e9be33f157 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el @@ -77,40 +77,46 @@ (ert-deftest file-notify-test00-availability () "Test availability of `file-notify'." + :expected-result (if file-notify-support :passed :failed) (should (memq file-notify-support '(gfilenotify inotify w32notify)))) -(ert-deftest file-notify-test01-add-watch () - "Check `file-notify-add-watch'." - (let (desc) - ;; Check, that different valid parameters are accepted. - (should (setq desc (file-notify-add-watch - temporary-file-directory '(change) 'ignore))) - (file-notify-rm-watch desc) - (should (setq desc (file-notify-add-watch - temporary-file-directory '(attribute-change) 'ignore))) - (file-notify-rm-watch desc) - (should (setq desc (file-notify-add-watch - temporary-file-directory - '(change attribute-change) 'ignore))) - (file-notify-rm-watch desc) - - ;; Check error handling. - (should - (equal (car (should-error (file-notify-add-watch 1 2 3 4))) - 'wrong-number-of-arguments)) - (should - (equal (should-error (file-notify-add-watch 1 2 3)) - '(wrong-type-argument 1))) - (should - (equal (should-error (file-notify-add-watch temporary-file-directory 2 3)) - '(wrong-type-argument 2))) - (should - (equal (should-error (file-notify-add-watch - temporary-file-directory '(change) 3)) - '(wrong-type-argument 3))))) +(when file-notify-support -(file-notify--deftest-remote file-notify-test01-add-watch - "Check `file-notify-add-watch' for remote files.") + (ert-deftest file-notify-test01-add-watch () + "Check `file-notify-add-watch'." + (let (desc) + ;; Check, that different valid parameters are accepted. + (should (setq desc (file-notify-add-watch + temporary-file-directory '(change) 'ignore))) + (file-notify-rm-watch desc) + (should (setq desc (file-notify-add-watch + temporary-file-directory + '(attribute-change) 'ignore))) + (file-notify-rm-watch desc) + (should (setq desc (file-notify-add-watch + temporary-file-directory + '(change attribute-change) 'ignore))) + (file-notify-rm-watch desc) + + ;; Check error handling. + (should + (equal (car (should-error (file-notify-add-watch 1 2 3 4))) + 'wrong-number-of-arguments)) + (should + (equal (should-error (file-notify-add-watch 1 2 3)) + '(wrong-type-argument 1))) + (should + (equal (should-error (file-notify-add-watch + temporary-file-directory 2 3)) + '(wrong-type-argument 2))) + (should + (equal (should-error (file-notify-add-watch + temporary-file-directory '(change) 3)) + '(wrong-type-argument 3))))) + + (file-notify--deftest-remote file-notify-test01-add-watch + "Check `file-notify-add-watch' for remote files.") + ) ;; file-notify-support (defun file-notify--test-event-test () "Ert test function to be called by `file-notify--test-event-handler'. @@ -141,52 +147,55 @@ Save the result in `file-notify--test-results', for later analysis." (expand-file-name (make-temp-name "file-notify-test") temporary-file-directory)) -(ert-deftest file-notify-test02-events () - "Check file creation/removal notifications." - (let (desc) - (unwind-protect - (progn - (setq file-notify--test-results nil - file-notify--test-tmpfile (file-notify--test-make-temp-name) - file-notify--test-tmpfile1 (file-notify--test-make-temp-name) - desc - (file-notify-add-watch - file-notify--test-tmpfile - '(change) 'file-notify--test-event-handler)) - - ;; Check creation and removal. - (write-region "any text" nil file-notify--test-tmpfile) - (delete-file file-notify--test-tmpfile) - - ;; Check copy and rename. - (write-region "any text" nil file-notify--test-tmpfile) - (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) - (delete-file file-notify--test-tmpfile) - (delete-file file-notify--test-tmpfile1) - - (write-region "any text" nil file-notify--test-tmpfile) - (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) - (delete-file file-notify--test-tmpfile1)) - - ;; Wait for events, and exit. - (sit-for 5 'nodisplay) - (file-notify-rm-watch desc) - (ignore-errors (delete-file file-notify--test-tmpfile)) - (ignore-errors (delete-file file-notify--test-tmpfile1)))) +(when file-notify-support + + (ert-deftest file-notify-test02-events () + "Check file creation/removal notifications." + (let (desc) + (unwind-protect + (progn + (setq file-notify--test-results nil + file-notify--test-tmpfile (file-notify--test-make-temp-name) + file-notify--test-tmpfile1 (file-notify--test-make-temp-name) + desc + (file-notify-add-watch + file-notify--test-tmpfile + '(change) 'file-notify--test-event-handler)) + + ;; Check creation and removal. + (write-region "any text" nil file-notify--test-tmpfile) + (delete-file file-notify--test-tmpfile) + + ;; Check copy and rename. + (write-region "any text" nil file-notify--test-tmpfile) + (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) + (delete-file file-notify--test-tmpfile) + (delete-file file-notify--test-tmpfile1) + + (write-region "any text" nil file-notify--test-tmpfile) + (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) + (delete-file file-notify--test-tmpfile1)) + + ;; Wait for events, and exit. + (sit-for 5 'nodisplay) + (file-notify-rm-watch desc) + (ignore-errors (delete-file file-notify--test-tmpfile)) + (ignore-errors (delete-file file-notify--test-tmpfile1)))) - (dolist (result file-notify--test-results) - ;(message "%s" (ert-test-result-messages result)) - (when (ert-test-failed-p result) - (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) + (dolist (result file-notify--test-results) + ;(message "%s" (ert-test-result-messages result)) + (when (ert-test-failed-p result) + (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) -(file-notify--deftest-remote file-notify-test02-events - "Check file creation/removal notifications for remote files.") + (file-notify--deftest-remote file-notify-test02-events + "Check file creation/removal notifications for remote files.") + ) ;; file-notify-support ;; autorevert runs only in interactive mode. (defvar auto-revert-remote-files) (setq auto-revert-remote-files t) (require 'autorevert) -(when (null noninteractive) +(when (and file-notify-support (null noninteractive)) (ert-deftest file-notify-test03-autorevert () "Check autorevert via file notification. @@ -240,7 +249,7 @@ This test is skipped in batch mode." (file-notify--deftest-remote file-notify-test03-autorevert "Check autorevert via file notification for remote files. This test is skipped in batch mode.") - ) ;; (null noninteractive) + ) ;; (and file-notify-support (null noninteractive)) (defun file-notify-test-all (&optional interactive) "Run all tests for \\[file-notify]." diff --git a/test/automated/files.el b/test/automated/files.el index f2d2192a420..8ce2ed7230c 100644 --- a/test/automated/files.el +++ b/test/automated/files.el @@ -146,4 +146,7 @@ form.") (should (file-test--do-local-variables-test str subtest)))))) (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) +;; Stop the above "Local Var..." confusing Emacs. + + ;;; files.el ends here diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el index 9cc87b608ad..03a8fb08bc5 100644 --- a/test/automated/flymake-tests.el +++ b/test/automated/flymake-tests.el @@ -25,9 +25,6 @@ (require 'ert) (require 'flymake) -(defgroup flymake-tests nil - "Test suite for flymake.") - ;; Warning predicate (defun flymake-tests--current-face (file predicate) diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index bca462da4d9..28fa47630a8 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -1194,8 +1194,7 @@ Argument INPUT icalendar event string." (should (string= org-input cycled))))) ;; clean up (kill-buffer (find-buffer-visiting temp-diary)) - (save-excursion - (set-buffer (find-buffer-visiting temp-ics)) + (with-current-buffer (find-buffer-visiting temp-ics) (set-buffer-modified-p nil) (kill-buffer (current-buffer))) (delete-file temp-diary) diff --git a/test/automated/imenu-test.el b/test/automated/imenu-test.el index 83e19ebd914..b2b0c6b5c31 100644 --- a/test/automated/imenu-test.el +++ b/test/automated/imenu-test.el @@ -22,6 +22,7 @@ ;;; Code: +(require 'ert) (require 'imenu) ;; (imenu-simple-scan-deftest-gather-strings-from-list diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el index 175f262b282..b4d20cf4fb1 100644 --- a/test/automated/inotify-test.el +++ b/test/automated/inotify-test.el @@ -25,6 +25,9 @@ (require 'ert) +(declare-function inotify-add-watch "inotify.c" (file-name aspect callback)) +(declare-function inotify-rm-watch "inotify.c" (watch-descriptor)) + (when (featurep 'inotify) ;; (ert-deftest filewatch-file-watch-aspects-check () @@ -45,7 +48,7 @@ (let ((temp-file (make-temp-file "inotify-simple")) (events 0)) (let ((wd - (inotify-add-watch temp-file t (lambda (ev) + (inotify-add-watch temp-file t (lambda (_ev) (setq events (1+ events)))))) (unwind-protect (progn diff --git a/test/automated/package-test.el b/test/automated/package-test.el index 706ba953d98..a5f0ebb1f94 100755 --- a/test/automated/package-test.el +++ b/test/automated/package-test.el @@ -142,6 +142,9 @@ (let ((help-xref-following t)) ,@body))) +(autoload 'makeinfo-buffer "makeinfo") +(defvar compilation-in-progress) + (defun package-test-install-texinfo (file) "Install from texinfo FILE. @@ -156,7 +159,6 @@ FILE should be a .texinfo file relative to the current (with-current-buffer (find-file-literally full-file) (unwind-protect (progn - (require 'makeinfo) (makeinfo-buffer) ;; Give `makeinfo-buffer' a chance to finish (while compilation-in-progress @@ -184,6 +186,9 @@ DIR is the base name of the package directory, without the trailing slash" (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) (delete-file file)))) +(defvar tar-parse-info) +(declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct + (defun package-test-search-tar-file (filename) "Search the current buffer's `tar-parse-info' variable for FILENAME. diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el index b8f2a23f6d5..beb18358085 100755 --- a/test/automated/package-x-test.el +++ b/test/automated/package-x-test.el @@ -35,6 +35,7 @@ (require 'package-x) (require 'ert) (require 'cl-lib) +(eval-when-compile (require 'package-test)) ;; package-test is not normally in `load-path', so temporarily set ;; `load-path' to contain the current directory. diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 40505cc7953..1dffe9544fe 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -21,6 +21,7 @@ ;;; Code: +(require 'ert) (require 'python) (defmacro python-tests-with-temp-buffer (contents &rest body) @@ -463,10 +464,10 @@ Class foo(object): " (python-tests-look-at "3)") (forward-line 1) - (= (python-indent-calculate-indentation) 12) + (should (= (python-indent-calculate-indentation) 8)) (python-tests-look-at "pass") (forward-line 1) - (= (python-indent-calculate-indentation) 8))) + (should (= (python-indent-calculate-indentation) 8)))) ;;; Navigation diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 02582e8ad2d..ad805f16777 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -21,6 +21,7 @@ ;;; Code: +(require 'ert) (require 'ruby-mode) (defun ruby-should-indent (content column) @@ -474,29 +475,30 @@ VALUES-PLIST is a list with alternating index and value elements." (with-temp-buffer (insert ruby-block-test-example) (ruby-mode) + (goto-char (point-min)) ,@body))) (put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) (ruby-deftest-move-to-block works-on-do - (goto-line 11) + (forward-line 10) (ruby-end-of-block) (should (= 13 (line-number-at-pos))) (ruby-beginning-of-block) (should (= 11 (line-number-at-pos)))) (ruby-deftest-move-to-block zero-is-noop - (goto-line 5) + (forward-line 4) (ruby-move-to-block 0) (should (= 5 (line-number-at-pos)))) (ruby-deftest-move-to-block ok-with-three - (goto-line 2) + (forward-line 1) (ruby-move-to-block 3) (should (= 14 (line-number-at-pos)))) (ruby-deftest-move-to-block ok-with-minus-two - (goto-line 10) + (forward-line 9) (ruby-move-to-block -2) (should (= 2 (line-number-at-pos)))) @@ -514,7 +516,7 @@ VALUES-PLIST is a list with alternating index and value elements." | | |end"))) (ruby-with-temp-buffer s - (goto-line 1) + (goto-char (point-min)) (ruby-end-of-block) (should (= 5 (line-number-at-pos))) (ruby-beginning-of-block) @@ -529,7 +531,7 @@ VALUES-PLIST is a list with alternating index and value elements." | end | eowarn |end") - (goto-line 1) + (goto-char (point-min)) (ruby-end-of-block) (should (= 6 (line-number-at-pos))) (ruby-beginning-of-block) @@ -541,7 +543,6 @@ VALUES-PLIST is a list with alternating index and value elements." "foo do | Module.to_s |end") - (end-of-buffer) (let ((case-fold-search t)) (ruby-beginning-of-block)) (should (= 1 (line-number-at-pos))))) @@ -553,7 +554,8 @@ VALUES-PLIST is a list with alternating index and value elements." | end |else |end") - (goto-line 4) + (goto-char (point-min)) + (forward-line 3) (ruby-beginning-of-block) (should (= 1 (line-number-at-pos))))) @@ -565,7 +567,8 @@ VALUES-PLIST is a list with alternating index and value elements." | Class.to_s | end |end") - (goto-line 4) + (goto-char (point-min)) + (forward-line 3) (let ((case-fold-search t)) (beginning-of-defun)) (should (= 2 (line-number-at-pos))))) @@ -578,7 +581,8 @@ VALUES-PLIST is a list with alternating index and value elements." | 'ho hum' | end |end") - (goto-line 2) + (goto-char (point-min)) + (forward-line 1) (end-of-defun) (should (= 5 (line-number-at-pos))))) diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el index 98b0c52728b..87c55c5d374 100644 --- a/test/automated/undo-tests.el +++ b/test/automated/undo-tests.el @@ -200,6 +200,32 @@ '(error "Unrecognized entry in undo list \"bogus\"")))) (buffer-string)))))) +;; http://debbugs.gnu.org/14824 +(ert-deftest undo-test-buffer-modified () + "Test undoing marks buffer unmodified." + (with-temp-buffer + (buffer-enable-undo) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + +(ert-deftest undo-test-file-modified () + "Test undoing marks buffer visiting file unmodified." + (let ((tempfile (make-temp-file "undo-test"))) + (unwind-protect + (progn + (with-current-buffer (find-file-noselect tempfile) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + (delete-file tempfile)))) + (defun undo-test-all (&optional interactive) "Run all tests for \\[undo]." (interactive "p") diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el index 874ae01affb..9157a0d3002 100644 --- a/test/automated/xml-parse-tests.el +++ b/test/automated/xml-parse-tests.el @@ -27,6 +27,7 @@ ;;; Code: +(require 'ert) (require 'xml) (defvar xml-parse-tests--data |