diff options
| author | Tom Tromey | 2013-07-26 14:02:53 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-07-26 14:02:53 -0600 |
| commit | cc231cbe45d27a1906d268fb72d3b4105a2e9c65 (patch) | |
| tree | c011828e2a3a18e77eaa8849e3cccb805d798f42 /test | |
| parent | b34a529f177a6ea32da5cb1254f91bf9d71838db (diff) | |
| parent | fec9206062b420aca84f53d05a72c3ee43244022 (diff) | |
| download | emacs-cc231cbe45d27a1906d268fb72d3b4105a2e9c65.tar.gz emacs-cc231cbe45d27a1906d268fb72d3b4105a2e9c65.zip | |
merge from trunk
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 27 | ||||
| -rw-r--r-- | test/automated/Makefile.in | 3 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 47 | ||||
| -rw-r--r-- | test/automated/inotify-test.el | 4 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 47 | ||||
| -rw-r--r-- | test/automated/subword-tests.el | 50 |
6 files changed, 159 insertions, 19 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index d3d8db6b501..bffe85e6a7a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2013-07-24 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * automated/file-notify-tests.el | ||
| 4 | (file-notify--test-local-enabled): New defconst. Replaces all | ||
| 5 | `file-notify-support' occurences. | ||
| 6 | (file-notify--test-remote-enabled): New defun. | ||
| 7 | (file-notify--deftest-remote): Use it. | ||
| 8 | (file-notify-test00-availability): Rewrite. | ||
| 9 | (file-notify-test00-availability-remote): New defun. | ||
| 10 | (file-notify-test01-add-watch): Rewrite first erroneous check. | ||
| 11 | |||
| 12 | 2013-07-23 Glenn Morris <rgm@gnu.org> | ||
| 13 | |||
| 14 | * automated/inotify-test.el (inotify-file-watch-simple): | ||
| 15 | Delete temp-file when done. | ||
| 16 | |||
| 17 | * automated/subword-tests.el: Require subword. | ||
| 18 | |||
| 19 | 2013-07-22 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 20 | |||
| 21 | * automated/subword-tests.el: New file. | ||
| 22 | |||
| 23 | 2013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 24 | |||
| 25 | * automated/python-tests.el (python-imenu-create-index-2) | ||
| 26 | (python-imenu-create-index-3): New tests. | ||
| 27 | |||
| 1 | 2013-07-11 Glenn Morris <rgm@gnu.org> | 28 | 2013-07-11 Glenn Morris <rgm@gnu.org> |
| 2 | 29 | ||
| 3 | * automated/ert-tests.el: Require cl-lib at runtime too. | 30 | * automated/ert-tests.el: Require cl-lib at runtime too. |
diff --git a/test/automated/Makefile.in b/test/automated/Makefile.in index 6e7111e589c..d4bfcc12130 100644 --- a/test/automated/Makefile.in +++ b/test/automated/Makefile.in | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | # Maintenance productions for the automated test directory | 1 | ### @configure_input@ |
| 2 | |||
| 2 | # Copyright (C) 2010-2013 Free Software Foundation, Inc. | 3 | # Copyright (C) 2010-2013 Free Software Foundation, Inc. |
| 3 | 4 | ||
| 4 | # This file is part of GNU Emacs. | 5 | # This file is part of GNU Emacs. |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 0e9be33f157..8bd4f258b1c 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -47,13 +47,21 @@ | |||
| 47 | tramp-message-show-message nil) | 47 | tramp-message-show-message nil) |
| 48 | (when noninteractive (defalias 'tramp-read-passwd 'ignore)) | 48 | (when noninteractive (defalias 'tramp-read-passwd 'ignore)) |
| 49 | 49 | ||
| 50 | ;; We do not want to try and fail `file-notify-add-watch'. | ||
| 51 | (defconst file-notify--test-local-enabled file-notify--library | ||
| 52 | "Whether local file notification is enabled.") | ||
| 53 | |||
| 54 | ;; We need also a check on the remote side, w/o adding a file monitor. | ||
| 55 | (defun file-notify--test-remote-enabled () | ||
| 56 | "Whether remote file notification is enabled." | ||
| 57 | (ignore-errors | ||
| 58 | (and (file-remote-p file-notify-test-remote-temporary-file-directory) | ||
| 59 | (file-directory-p file-notify-test-remote-temporary-file-directory) | ||
| 60 | (file-writable-p file-notify-test-remote-temporary-file-directory)))) | ||
| 61 | |||
| 50 | (defmacro file-notify--deftest-remote (test docstring) | 62 | (defmacro file-notify--deftest-remote (test docstring) |
| 51 | "Define ert `TEST-remote' for remote files." | 63 | "Define ert `TEST-remote' for remote files." |
| 52 | `(when (ignore-errors | 64 | `(when (and (file-notify--test-remote-enabled) (ert-get-test ',test)) |
| 53 | (and | ||
| 54 | (file-remote-p file-notify-test-remote-temporary-file-directory) | ||
| 55 | (file-directory-p file-notify-test-remote-temporary-file-directory) | ||
| 56 | (file-writable-p file-notify-test-remote-temporary-file-directory))) | ||
| 57 | ;; Define the test. | 65 | ;; Define the test. |
| 58 | (ert-deftest ,(intern (concat (symbol-name test) "-remote")) () | 66 | (ert-deftest ,(intern (concat (symbol-name test) "-remote")) () |
| 59 | ,docstring | 67 | ,docstring |
| @@ -77,10 +85,16 @@ | |||
| 77 | 85 | ||
| 78 | (ert-deftest file-notify-test00-availability () | 86 | (ert-deftest file-notify-test00-availability () |
| 79 | "Test availability of `file-notify'." | 87 | "Test availability of `file-notify'." |
| 80 | :expected-result (if file-notify-support :passed :failed) | 88 | (let (desc) |
| 81 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) | 89 | ;; Check, that different valid parameters are accepted. |
| 90 | (should (setq desc (file-notify-add-watch | ||
| 91 | temporary-file-directory '(change) 'ignore))) | ||
| 92 | (file-notify-rm-watch desc))) | ||
| 93 | |||
| 94 | (file-notify--deftest-remote file-notify-test00-availability | ||
| 95 | "Test availability of `file-notify' for remote files.") | ||
| 82 | 96 | ||
| 83 | (when file-notify-support | 97 | (when file-notify--test-local-enabled |
| 84 | 98 | ||
| 85 | (ert-deftest file-notify-test01-add-watch () | 99 | (ert-deftest file-notify-test01-add-watch () |
| 86 | "Check `file-notify-add-watch'." | 100 | "Check `file-notify-add-watch'." |
| @@ -99,9 +113,8 @@ | |||
| 99 | (file-notify-rm-watch desc) | 113 | (file-notify-rm-watch desc) |
| 100 | 114 | ||
| 101 | ;; Check error handling. | 115 | ;; Check error handling. |
| 102 | (should | 116 | (should-error (file-notify-add-watch 1 2 3 4) |
| 103 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | 117 | :type 'wrong-number-of-arguments) |
| 104 | 'wrong-number-of-arguments)) | ||
| 105 | (should | 118 | (should |
| 106 | (equal (should-error (file-notify-add-watch 1 2 3)) | 119 | (equal (should-error (file-notify-add-watch 1 2 3)) |
| 107 | '(wrong-type-argument 1))) | 120 | '(wrong-type-argument 1))) |
| @@ -116,7 +129,7 @@ | |||
| 116 | 129 | ||
| 117 | (file-notify--deftest-remote file-notify-test01-add-watch | 130 | (file-notify--deftest-remote file-notify-test01-add-watch |
| 118 | "Check `file-notify-add-watch' for remote files.") | 131 | "Check `file-notify-add-watch' for remote files.") |
| 119 | ) ;; file-notify-support | 132 | ) ;; file-notify--test-local-enabled |
| 120 | 133 | ||
| 121 | (defun file-notify--test-event-test () | 134 | (defun file-notify--test-event-test () |
| 122 | "Ert test function to be called by `file-notify--test-event-handler'. | 135 | "Ert test function to be called by `file-notify--test-event-handler'. |
| @@ -147,7 +160,7 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 147 | (expand-file-name | 160 | (expand-file-name |
| 148 | (make-temp-name "file-notify-test") temporary-file-directory)) | 161 | (make-temp-name "file-notify-test") temporary-file-directory)) |
| 149 | 162 | ||
| 150 | (when file-notify-support | 163 | (when file-notify--test-local-enabled |
| 151 | 164 | ||
| 152 | (ert-deftest file-notify-test02-events () | 165 | (ert-deftest file-notify-test02-events () |
| 153 | "Check file creation/removal notifications." | 166 | "Check file creation/removal notifications." |
| @@ -189,13 +202,13 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 189 | 202 | ||
| 190 | (file-notify--deftest-remote file-notify-test02-events | 203 | (file-notify--deftest-remote file-notify-test02-events |
| 191 | "Check file creation/removal notifications for remote files.") | 204 | "Check file creation/removal notifications for remote files.") |
| 192 | ) ;; file-notify-support | 205 | ) ;; file-notify--test-local-enabled |
| 193 | 206 | ||
| 194 | ;; autorevert runs only in interactive mode. | 207 | ;; autorevert runs only in interactive mode. |
| 195 | (defvar auto-revert-remote-files) | 208 | (defvar auto-revert-remote-files) |
| 196 | (setq auto-revert-remote-files t) | 209 | (setq auto-revert-remote-files t) |
| 197 | (require 'autorevert) | 210 | (require 'autorevert) |
| 198 | (when (and file-notify-support (null noninteractive)) | 211 | (when (and file-notify--test-local-enabled (null noninteractive)) |
| 199 | 212 | ||
| 200 | (ert-deftest file-notify-test03-autorevert () | 213 | (ert-deftest file-notify-test03-autorevert () |
| 201 | "Check autorevert via file notification. | 214 | "Check autorevert via file notification. |
| @@ -249,12 +262,12 @@ This test is skipped in batch mode." | |||
| 249 | (file-notify--deftest-remote file-notify-test03-autorevert | 262 | (file-notify--deftest-remote file-notify-test03-autorevert |
| 250 | "Check autorevert via file notification for remote files. | 263 | "Check autorevert via file notification for remote files. |
| 251 | This test is skipped in batch mode.") | 264 | This test is skipped in batch mode.") |
| 252 | ) ;; (and file-notify-support (null noninteractive)) | 265 | ) ;; (and file-notify--test-local-enabled (null noninteractive)) |
| 253 | 266 | ||
| 254 | (defun file-notify-test-all (&optional interactive) | 267 | (defun file-notify-test-all (&optional interactive) |
| 255 | "Run all tests for \\[file-notify]." | 268 | "Run all tests for \\[file-notify]." |
| 256 | (interactive "p") | 269 | (interactive "p") |
| 257 | (when file-notify-support | 270 | (when file-notify--test-local-enabled |
| 258 | (if interactive | 271 | (if interactive |
| 259 | (ert-run-tests-interactively "^file-notify-") | 272 | (ert-run-tests-interactively "^file-notify-") |
| 260 | (ert-run-tests-batch "^file-notify-")))) | 273 | (ert-run-tests-batch "^file-notify-")))) |
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el index b4d20cf4fb1..97d78dcb58e 100644 --- a/test/automated/inotify-test.el +++ b/test/automated/inotify-test.el | |||
| @@ -56,8 +56,10 @@ | |||
| 56 | (insert "Foo\n")) | 56 | (insert "Foo\n")) |
| 57 | (sit-for 5) ;; Hacky. Wait for 5s until events are processed | 57 | (sit-for 5) ;; Hacky. Wait for 5s until events are processed |
| 58 | (should (> events 0))) | 58 | (should (> events 0))) |
| 59 | (inotify-rm-watch wd))))) | 59 | (inotify-rm-watch wd) |
| 60 | (delete-file temp-file))))) | ||
| 60 | ) | 61 | ) |
| 61 | 62 | ||
| 62 | (provide 'inotify-tests) | 63 | (provide 'inotify-tests) |
| 64 | |||
| 63 | ;;; inotify-tests.el ends here. | 65 | ;;; inotify-tests.el ends here. |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 1dffe9544fe..fdae235ad38 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -1745,6 +1745,53 @@ class Baz(object): | |||
| 1745 | (cons "c (def)" (copy-marker 626))))) | 1745 | (cons "c (def)" (copy-marker 626))))) |
| 1746 | (python-imenu-create-index))))) | 1746 | (python-imenu-create-index))))) |
| 1747 | 1747 | ||
| 1748 | (ert-deftest python-imenu-create-index-2 () | ||
| 1749 | (python-tests-with-temp-buffer | ||
| 1750 | " | ||
| 1751 | class Foo(object): | ||
| 1752 | def foo(self): | ||
| 1753 | def foo1(): | ||
| 1754 | pass | ||
| 1755 | |||
| 1756 | def foobar(self): | ||
| 1757 | pass | ||
| 1758 | " | ||
| 1759 | (goto-char (point-max)) | ||
| 1760 | (should (equal | ||
| 1761 | (list | ||
| 1762 | (list | ||
| 1763 | "Foo (class)" | ||
| 1764 | (cons "*class definition*" (copy-marker 2)) | ||
| 1765 | (list | ||
| 1766 | "foo (def)" | ||
| 1767 | (cons "*function definition*" (copy-marker 21)) | ||
| 1768 | (cons "foo1 (def)" (copy-marker 40))) | ||
| 1769 | (cons "foobar (def)" (copy-marker 78)))) | ||
| 1770 | (python-imenu-create-index))))) | ||
| 1771 | |||
| 1772 | (ert-deftest python-imenu-create-index-3 () | ||
| 1773 | (python-tests-with-temp-buffer | ||
| 1774 | " | ||
| 1775 | class Foo(object): | ||
| 1776 | def foo(self): | ||
| 1777 | def foo1(): | ||
| 1778 | pass | ||
| 1779 | def foo2(): | ||
| 1780 | pass | ||
| 1781 | " | ||
| 1782 | (goto-char (point-max)) | ||
| 1783 | (should (equal | ||
| 1784 | (list | ||
| 1785 | (list | ||
| 1786 | "Foo (class)" | ||
| 1787 | (cons "*class definition*" (copy-marker 2)) | ||
| 1788 | (list | ||
| 1789 | "foo (def)" | ||
| 1790 | (cons "*function definition*" (copy-marker 21)) | ||
| 1791 | (cons "foo1 (def)" (copy-marker 40)) | ||
| 1792 | (cons "foo2 (def)" (copy-marker 77))))) | ||
| 1793 | (python-imenu-create-index))))) | ||
| 1794 | |||
| 1748 | (ert-deftest python-imenu-create-flat-index-1 () | 1795 | (ert-deftest python-imenu-create-flat-index-1 () |
| 1749 | (python-tests-with-temp-buffer | 1796 | (python-tests-with-temp-buffer |
| 1750 | " | 1797 | " |
diff --git a/test/automated/subword-tests.el b/test/automated/subword-tests.el new file mode 100644 index 00000000000..2137cd7d908 --- /dev/null +++ b/test/automated/subword-tests.el | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | ;;; subword-tests.el --- Testing the subword rules | ||
| 2 | |||
| 3 | ;; Copyright (C) 2011-2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This program is free software; you can redistribute it and/or modify | ||
| 9 | ;; it under the terms of the GNU General Public License as published by | ||
| 10 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 11 | ;; (at your option) any later version. | ||
| 12 | |||
| 13 | ;; This program is distributed in the hope that it will be useful, | ||
| 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | ;; GNU General Public License for more details. | ||
| 17 | |||
| 18 | ;; You should have received a copy of the GNU General Public License | ||
| 19 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | ;;; Commentary: | ||
| 22 | |||
| 23 | ;; | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (require 'ert) | ||
| 28 | (require 'subword) | ||
| 29 | |||
| 30 | (defconst subword-tests-strings | ||
| 31 | '("ABC^" ;;Bug#13758 | ||
| 32 | "ABC^ ABC^Foo^ ABC^-Foo^ toto^ ABC^")) | ||
| 33 | |||
| 34 | (ert-deftest subword-tests () | ||
| 35 | "Test the `subword-mode' rules." | ||
| 36 | (with-temp-buffer | ||
| 37 | (dolist (str subword-tests-strings) | ||
| 38 | (erase-buffer) | ||
| 39 | (insert str) | ||
| 40 | (goto-char (point-min)) | ||
| 41 | (while (search-forward "^" nil t) | ||
| 42 | (replace-match "")) | ||
| 43 | (goto-char (point-min)) | ||
| 44 | (while (not (eobp)) | ||
| 45 | (subword-forward 1) | ||
| 46 | (insert "^")) | ||
| 47 | (should (equal (buffer-string) str))))) | ||
| 48 | |||
| 49 | (provide 'subword-tests) | ||
| 50 | ;;; subword-tests.el ends here | ||