diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/so-long-tests/autoload-longlines-mode-tests.el | 1 | ||||
| -rw-r--r-- | test/lisp/so-long-tests/autoload-major-mode-tests.el | 1 | ||||
| -rw-r--r-- | test/lisp/so-long-tests/autoload-minor-mode-tests.el | 1 | ||||
| -rw-r--r-- | test/lisp/so-long-tests/so-long-tests.el | 116 | ||||
| -rw-r--r-- | test/lisp/so-long-tests/spelling-tests.el | 69 |
5 files changed, 183 insertions, 5 deletions
diff --git a/test/lisp/so-long-tests/autoload-longlines-mode-tests.el b/test/lisp/so-long-tests/autoload-longlines-mode-tests.el index 5a57e049fb5..c94aeaef24b 100644 --- a/test/lisp/so-long-tests/autoload-longlines-mode-tests.el +++ b/test/lisp/so-long-tests/autoload-longlines-mode-tests.el | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | (ert-deftest so-long-tests-autoload-longlines-mode () | 40 | (ert-deftest so-long-tests-autoload-longlines-mode () |
| 41 | "File-local -*- so-long-action: longlines-mode; eval: (so-long) -*-" | 41 | "File-local -*- so-long-action: longlines-mode; eval: (so-long) -*-" |
| 42 | (with-temp-buffer | 42 | (with-temp-buffer |
| 43 | (display-buffer (current-buffer)) | ||
| 43 | (so-long-tests-remember) | 44 | (so-long-tests-remember) |
| 44 | (insert "-*- so-long-action: longlines-mode; eval: (so-long) -*-\n") | 45 | (insert "-*- so-long-action: longlines-mode; eval: (so-long) -*-\n") |
| 45 | (put 'so-long-action 'safe-local-variable #'symbolp) | 46 | (put 'so-long-action 'safe-local-variable #'symbolp) |
diff --git a/test/lisp/so-long-tests/autoload-major-mode-tests.el b/test/lisp/so-long-tests/autoload-major-mode-tests.el index d82cb59750c..a8f6f9e7b32 100644 --- a/test/lisp/so-long-tests/autoload-major-mode-tests.el +++ b/test/lisp/so-long-tests/autoload-major-mode-tests.el | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | (ert-deftest so-long-tests-autoload-major-mode () | 38 | (ert-deftest so-long-tests-autoload-major-mode () |
| 39 | "File-local -*- so-long -*-" | 39 | "File-local -*- so-long -*-" |
| 40 | (with-temp-buffer | 40 | (with-temp-buffer |
| 41 | (display-buffer (current-buffer)) | ||
| 41 | (so-long-tests-remember) | 42 | (so-long-tests-remember) |
| 42 | (insert "-*- so-long -*-\n") | 43 | (insert "-*- so-long -*-\n") |
| 43 | (normal-mode) | 44 | (normal-mode) |
diff --git a/test/lisp/so-long-tests/autoload-minor-mode-tests.el b/test/lisp/so-long-tests/autoload-minor-mode-tests.el index 67f1903c09c..600a35de0a9 100644 --- a/test/lisp/so-long-tests/autoload-minor-mode-tests.el +++ b/test/lisp/so-long-tests/autoload-minor-mode-tests.el | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | (ert-deftest so-long-tests-autoload-minor-mode () | 39 | (ert-deftest so-long-tests-autoload-minor-mode () |
| 40 | "File-local -*- so-long-action: so-long-minor-mode; eval: (so-long) -*-" | 40 | "File-local -*- so-long-action: so-long-minor-mode; eval: (so-long) -*-" |
| 41 | (with-temp-buffer | 41 | (with-temp-buffer |
| 42 | (display-buffer (current-buffer)) | ||
| 42 | (so-long-tests-remember) | 43 | (so-long-tests-remember) |
| 43 | (insert "-*- so-long-action: so-long-minor-mode; eval: (so-long) -*-\n") | 44 | (insert "-*- so-long-action: so-long-minor-mode; eval: (so-long) -*-\n") |
| 44 | (put 'so-long-action 'safe-local-variable #'symbolp) | 45 | (put 'so-long-action 'safe-local-variable #'symbolp) |
diff --git a/test/lisp/so-long-tests/so-long-tests.el b/test/lisp/so-long-tests/so-long-tests.el index b1e0cb90d00..99af5e91ba0 100644 --- a/test/lisp/so-long-tests/so-long-tests.el +++ b/test/lisp/so-long-tests/so-long-tests.el | |||
| @@ -29,13 +29,19 @@ | |||
| 29 | ;; (We could consistently use the latter, but the mixture of approaches | 29 | ;; (We could consistently use the latter, but the mixture of approaches |
| 30 | ;; means that we're testing more things.) | 30 | ;; means that we're testing more things.) |
| 31 | 31 | ||
| 32 | ;; Running the tests with "make lisp/so-long-tests" is like: | 32 | ;; Running manually: |
| 33 | ;; | 33 | ;; |
| 34 | ;; HOME=/nonexistent EMACSLOADPATH= LC_ALL=C \ | 34 | ;; for test in lisp/so-long-tests/*-tests.el; do make ${test%.el}; done \ |
| 35 | ;; EMACS_TEST_DIRECTORY=/home/phil/emacs/trunk/repository/test \ | 35 | ;; 2>&1 | egrep -v '^(Loading|Source file|make|Changed to so-long-mode)' |
| 36 | ;; | ||
| 37 | ;; Which is equivalent to: | ||
| 38 | ;; | ||
| 39 | ;; for test in lisp/so-long-tests/*-tests.el; do \ | ||
| 40 | ;; HOME=/nonexistent EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=. \ | ||
| 36 | ;; "../src/emacs" --no-init-file --no-site-file --no-site-lisp \ | 41 | ;; "../src/emacs" --no-init-file --no-site-file --no-site-lisp \ |
| 37 | ;; -L ":." -l ert -l lisp/so-long-tests.el --batch --eval \ | 42 | ;; -L ":." -l ert -l "$test" --batch --eval \ |
| 38 | ;; '(ert-run-tests-batch-and-exit (quote (not (tag :unstable))))' | 43 | ;; '(ert-run-tests-batch-and-exit (quote (not (tag :unstable))))'; \ |
| 44 | ;; done 2>&1 | egrep -v '^(Loading|Source file|Changed to so-long-mode)' | ||
| 39 | ;; | 45 | ;; |
| 40 | ;; See also `ert-run-tests-batch-and-exit'. | 46 | ;; See also `ert-run-tests-batch-and-exit'. |
| 41 | 47 | ||
| @@ -58,6 +64,7 @@ | |||
| 58 | (ert-deftest so-long-tests-threshold-under () | 64 | (ert-deftest so-long-tests-threshold-under () |
| 59 | "Under line length threshold." | 65 | "Under line length threshold." |
| 60 | (with-temp-buffer | 66 | (with-temp-buffer |
| 67 | (display-buffer (current-buffer)) | ||
| 61 | (insert "#!emacs\n") | 68 | (insert "#!emacs\n") |
| 62 | (insert (make-string (1- so-long-threshold) ?x)) | 69 | (insert (make-string (1- so-long-threshold) ?x)) |
| 63 | (normal-mode) | 70 | (normal-mode) |
| @@ -66,6 +73,7 @@ | |||
| 66 | (ert-deftest so-long-tests-threshold-at () | 73 | (ert-deftest so-long-tests-threshold-at () |
| 67 | "At line length threshold." | 74 | "At line length threshold." |
| 68 | (with-temp-buffer | 75 | (with-temp-buffer |
| 76 | (display-buffer (current-buffer)) | ||
| 69 | (insert "#!emacs\n") | 77 | (insert "#!emacs\n") |
| 70 | (insert (make-string (1- so-long-threshold) ?x)) | 78 | (insert (make-string (1- so-long-threshold) ?x)) |
| 71 | (normal-mode) | 79 | (normal-mode) |
| @@ -74,6 +82,7 @@ | |||
| 74 | (ert-deftest so-long-tests-threshold-over () | 82 | (ert-deftest so-long-tests-threshold-over () |
| 75 | "Over line length threshold." | 83 | "Over line length threshold." |
| 76 | (with-temp-buffer | 84 | (with-temp-buffer |
| 85 | (display-buffer (current-buffer)) | ||
| 77 | (insert "#!emacs\n") | 86 | (insert "#!emacs\n") |
| 78 | (normal-mode) | 87 | (normal-mode) |
| 79 | (so-long-tests-remember) | 88 | (so-long-tests-remember) |
| @@ -85,12 +94,14 @@ | |||
| 85 | "Skip leading shebang, whitespace, and comments." | 94 | "Skip leading shebang, whitespace, and comments." |
| 86 | ;; Long comment, no newline. | 95 | ;; Long comment, no newline. |
| 87 | (with-temp-buffer | 96 | (with-temp-buffer |
| 97 | (display-buffer (current-buffer)) | ||
| 88 | (insert "#!emacs\n") | 98 | (insert "#!emacs\n") |
| 89 | (insert (make-string (1+ so-long-threshold) ?\;)) | 99 | (insert (make-string (1+ so-long-threshold) ?\;)) |
| 90 | (normal-mode) | 100 | (normal-mode) |
| 91 | (should (eq major-mode 'emacs-lisp-mode))) | 101 | (should (eq major-mode 'emacs-lisp-mode))) |
| 92 | ;; Long comment, with newline. | 102 | ;; Long comment, with newline. |
| 93 | (with-temp-buffer | 103 | (with-temp-buffer |
| 104 | (display-buffer (current-buffer)) | ||
| 94 | (insert "#!emacs\n") | 105 | (insert "#!emacs\n") |
| 95 | (insert (make-string (1+ so-long-threshold) ?\;)) | 106 | (insert (make-string (1+ so-long-threshold) ?\;)) |
| 96 | (insert "\n") | 107 | (insert "\n") |
| @@ -98,6 +109,7 @@ | |||
| 98 | (should (eq major-mode 'emacs-lisp-mode))) | 109 | (should (eq major-mode 'emacs-lisp-mode))) |
| 99 | ;; Long comment, with short text following. | 110 | ;; Long comment, with short text following. |
| 100 | (with-temp-buffer | 111 | (with-temp-buffer |
| 112 | (display-buffer (current-buffer)) | ||
| 101 | (insert "#!emacs\n") | 113 | (insert "#!emacs\n") |
| 102 | (insert (make-string (1+ so-long-threshold) ?\;)) | 114 | (insert (make-string (1+ so-long-threshold) ?\;)) |
| 103 | (insert "\n") | 115 | (insert "\n") |
| @@ -106,6 +118,7 @@ | |||
| 106 | (should (eq major-mode 'emacs-lisp-mode))) | 118 | (should (eq major-mode 'emacs-lisp-mode))) |
| 107 | ;; Long comment, with long text following. | 119 | ;; Long comment, with long text following. |
| 108 | (with-temp-buffer | 120 | (with-temp-buffer |
| 121 | (display-buffer (current-buffer)) | ||
| 109 | (insert "#!emacs\n") | 122 | (insert "#!emacs\n") |
| 110 | (insert (make-string (1+ so-long-threshold) ?\;)) | 123 | (insert (make-string (1+ so-long-threshold) ?\;)) |
| 111 | (insert "\n") | 124 | (insert "\n") |
| @@ -116,6 +129,7 @@ | |||
| 116 | (ert-deftest so-long-tests-max-lines () | 129 | (ert-deftest so-long-tests-max-lines () |
| 117 | "Give up after `so-long-max-lines'." | 130 | "Give up after `so-long-max-lines'." |
| 118 | (with-temp-buffer | 131 | (with-temp-buffer |
| 132 | (display-buffer (current-buffer)) | ||
| 119 | (insert "#!emacs\n") | 133 | (insert "#!emacs\n") |
| 120 | ;; Insert exactly `so-long-max-lines' non-comment lines, followed | 134 | ;; Insert exactly `so-long-max-lines' non-comment lines, followed |
| 121 | ;; by a long line. | 135 | ;; by a long line. |
| @@ -139,10 +153,91 @@ | |||
| 139 | (normal-mode) | 153 | (normal-mode) |
| 140 | (should (eq major-mode 'so-long-mode)))))) | 154 | (should (eq major-mode 'so-long-mode)))))) |
| 141 | 155 | ||
| 156 | (ert-deftest so-long-tests-invisible-buffer-function () | ||
| 157 | "Call `so-long-invisible-buffer-function' in invisible buffers." | ||
| 158 | ;; Visible buffer. | ||
| 159 | (with-temp-buffer | ||
| 160 | (display-buffer (current-buffer)) | ||
| 161 | (insert "#!emacs\n") | ||
| 162 | (normal-mode) | ||
| 163 | (so-long-tests-remember) | ||
| 164 | (insert (make-string (1+ so-long-threshold) ?x)) | ||
| 165 | (normal-mode) | ||
| 166 | (so-long-tests-assert-and-revert 'so-long-mode)) | ||
| 167 | ;; Invisible buffer. | ||
| 168 | (with-temp-buffer | ||
| 169 | (insert "#!emacs\n") | ||
| 170 | (normal-mode) | ||
| 171 | (so-long-tests-remember) | ||
| 172 | (insert (make-string (1+ so-long-threshold) ?x)) | ||
| 173 | (normal-mode) | ||
| 174 | (should (eq major-mode 'emacs-lisp-mode)) | ||
| 175 | (should (eq nil (get-buffer-window))) | ||
| 176 | ;; Displaying the buffer should invoke `so-long'. | ||
| 177 | (display-buffer (current-buffer)) | ||
| 178 | (should (window-live-p (get-buffer-window))) | ||
| 179 | (unless (version< emacs-version "27") | ||
| 180 | ;; From Emacs 27 the `display-buffer' call is insufficient. | ||
| 181 | ;; The various 'window change functions' are now invoked by the | ||
| 182 | ;; redisplay, and redisplay does nothing at all in batch mode, | ||
| 183 | ;; so we cannot test under this revised behaviour. Refer to: | ||
| 184 | ;; https://lists.gnu.org/archive/html/emacs-devel/2019-10/msg00971.html | ||
| 185 | ;; For interactive (non-batch) test runs, calling `redisplay' | ||
| 186 | ;; does do the trick; so do that first. | ||
| 187 | (redisplay) | ||
| 188 | (when noninteractive | ||
| 189 | ;; In batch mode we need to cheat, and just pretend that | ||
| 190 | ;; `redisplay' triggered `window-configuration-change-hook'. | ||
| 191 | ;; This means the test is not as useful, but it still covers | ||
| 192 | ;; part of the process, and so it's better than nothing. | ||
| 193 | ;; | ||
| 194 | ;; Also test `so-long--active', in case a future version of | ||
| 195 | ;; Emacs adds the framework necessary to make `redisplay' work | ||
| 196 | ;; in batch mode. | ||
| 197 | (unless (eq so-long--active t) | ||
| 198 | (run-window-configuration-change-hook)))) | ||
| 199 | (so-long-tests-assert-and-revert 'so-long-mode)) | ||
| 200 | ;; `so-long-invisible-buffer-function' is `nil'. | ||
| 201 | (with-temp-buffer | ||
| 202 | (insert "#!emacs\n") | ||
| 203 | (normal-mode) | ||
| 204 | (so-long-tests-remember) | ||
| 205 | (insert (make-string (1+ so-long-threshold) ?x)) | ||
| 206 | (let ((so-long-invisible-buffer-function nil)) | ||
| 207 | (normal-mode)) | ||
| 208 | (so-long-tests-assert-and-revert 'so-long-mode)) | ||
| 209 | ;; `so-long-invisible-buffer-function' is `so-long'. | ||
| 210 | (with-temp-buffer | ||
| 211 | (insert "#!emacs\n") | ||
| 212 | (normal-mode) | ||
| 213 | (so-long-tests-remember) | ||
| 214 | (insert (make-string (1+ so-long-threshold) ?x)) | ||
| 215 | (let ((so-long-invisible-buffer-function #'so-long)) | ||
| 216 | (normal-mode)) | ||
| 217 | (so-long-tests-assert-and-revert 'so-long-mode)) | ||
| 218 | ;; `so-long-invisible-buffer-function' is `ignore'. | ||
| 219 | (with-temp-buffer | ||
| 220 | (insert "#!emacs\n") | ||
| 221 | (normal-mode) | ||
| 222 | (so-long-tests-remember) | ||
| 223 | (insert (make-string (1+ so-long-threshold) ?x)) | ||
| 224 | (let ((so-long-invisible-buffer-function #'ignore)) | ||
| 225 | (normal-mode)) | ||
| 226 | (should (eq major-mode 'emacs-lisp-mode)) | ||
| 227 | (display-buffer (current-buffer)) | ||
| 228 | (unless (version< emacs-version "27") | ||
| 229 | ;; See the "Invisible buffer" case earlier in this function. | ||
| 230 | (redisplay) | ||
| 231 | (when noninteractive | ||
| 232 | (unless (eq so-long--active t) | ||
| 233 | (run-window-configuration-change-hook)))) | ||
| 234 | (should (eq major-mode 'emacs-lisp-mode)))) | ||
| 235 | |||
| 142 | (ert-deftest so-long-tests-actions () | 236 | (ert-deftest so-long-tests-actions () |
| 143 | "Test each of the standard actions." | 237 | "Test each of the standard actions." |
| 144 | (dolist (action (mapcar #'car so-long-action-alist)) | 238 | (dolist (action (mapcar #'car so-long-action-alist)) |
| 145 | (with-temp-buffer | 239 | (with-temp-buffer |
| 240 | (display-buffer (current-buffer)) | ||
| 146 | (insert "#!emacs\n") | 241 | (insert "#!emacs\n") |
| 147 | (normal-mode) | 242 | (normal-mode) |
| 148 | (so-long-tests-remember) | 243 | (so-long-tests-remember) |
| @@ -210,6 +305,7 @@ | |||
| 210 | "Targeted major modes." | 305 | "Targeted major modes." |
| 211 | ;; Test the `so-long-target-modes' user option. | 306 | ;; Test the `so-long-target-modes' user option. |
| 212 | (with-temp-buffer | 307 | (with-temp-buffer |
| 308 | (display-buffer (current-buffer)) | ||
| 213 | (insert "#!emacs\n") | 309 | (insert "#!emacs\n") |
| 214 | (insert (make-string (1+ so-long-threshold) ?x)) | 310 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 215 | ;; Nil target modes. | 311 | ;; Nil target modes. |
| @@ -233,6 +329,7 @@ | |||
| 233 | "Custom predicate function." | 329 | "Custom predicate function." |
| 234 | ;; Test the `so-long-predicate' user option. | 330 | ;; Test the `so-long-predicate' user option. |
| 235 | (with-temp-buffer | 331 | (with-temp-buffer |
| 332 | (display-buffer (current-buffer)) | ||
| 236 | (insert "#!emacs\n") | 333 | (insert "#!emacs\n") |
| 237 | ;; Always false. | 334 | ;; Always false. |
| 238 | (let ((so-long-predicate #'ignore)) | 335 | (let ((so-long-predicate #'ignore)) |
| @@ -257,6 +354,7 @@ | |||
| 257 | ;; valid for the file-locals to be on the second line after the shebang, | 354 | ;; valid for the file-locals to be on the second line after the shebang, |
| 258 | ;; but with the *.el filename we no longer need the shebang. | 355 | ;; but with the *.el filename we no longer need the shebang. |
| 259 | (with-temp-buffer | 356 | (with-temp-buffer |
| 357 | (display-buffer (current-buffer)) | ||
| 260 | (setq buffer-file-name (expand-file-name "so-long-tests-data.el")) | 358 | (setq buffer-file-name (expand-file-name "so-long-tests-data.el")) |
| 261 | (insert ";; -*- so-long-action:so-long-minor-mode; -*-\n") | 359 | (insert ";; -*- so-long-action:so-long-minor-mode; -*-\n") |
| 262 | (put 'so-long-action 'safe-local-variable #'symbolp) | 360 | (put 'so-long-action 'safe-local-variable #'symbolp) |
| @@ -275,6 +373,7 @@ | |||
| 275 | (normal-mode) | 373 | (normal-mode) |
| 276 | (so-long-tests-remember)) | 374 | (so-long-tests-remember)) |
| 277 | (with-temp-buffer | 375 | (with-temp-buffer |
| 376 | (display-buffer (current-buffer)) | ||
| 278 | (setq buffer-file-name (concat (make-temp-name "so-long-tests-") ".el")) | 377 | (setq buffer-file-name (concat (make-temp-name "so-long-tests-") ".el")) |
| 279 | (insert ";; -*- so-long-action:so-long-minor-mode; eval:(so-long) -*-\n") | 378 | (insert ";; -*- so-long-action:so-long-minor-mode; eval:(so-long) -*-\n") |
| 280 | (put 'so-long-action 'safe-local-variable #'symbolp) | 379 | (put 'so-long-action 'safe-local-variable #'symbolp) |
| @@ -314,6 +413,7 @@ | |||
| 314 | ;; Downgrade the action from major mode to minor mode. | 413 | ;; Downgrade the action from major mode to minor mode. |
| 315 | (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade) | 414 | (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade) |
| 316 | (with-temp-buffer | 415 | (with-temp-buffer |
| 416 | (display-buffer (current-buffer)) | ||
| 317 | (insert ,prop-line) | 417 | (insert ,prop-line) |
| 318 | (insert (make-string (1+ so-long-threshold) ?x)) | 418 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 319 | (insert ,local-vars) | 419 | (insert ,local-vars) |
| @@ -322,6 +422,7 @@ | |||
| 322 | ;; Do not treat the file-local mode specially. | 422 | ;; Do not treat the file-local mode specially. |
| 323 | (setq-default so-long-file-local-mode-function nil) | 423 | (setq-default so-long-file-local-mode-function nil) |
| 324 | (with-temp-buffer | 424 | (with-temp-buffer |
| 425 | (display-buffer (current-buffer)) | ||
| 325 | (insert ,prop-line) | 426 | (insert ,prop-line) |
| 326 | (insert (make-string (1+ so-long-threshold) ?x)) | 427 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 327 | (insert ,local-vars) | 428 | (insert ,local-vars) |
| @@ -331,6 +432,7 @@ | |||
| 331 | (setq-default so-long-file-local-mode-function | 432 | (setq-default so-long-file-local-mode-function |
| 332 | #'so-long-tests-file-local-mode-function) | 433 | #'so-long-tests-file-local-mode-function) |
| 333 | (with-temp-buffer | 434 | (with-temp-buffer |
| 435 | (display-buffer (current-buffer)) | ||
| 334 | (insert ,prop-line) | 436 | (insert ,prop-line) |
| 335 | (insert (make-string (1+ so-long-threshold) ?x)) | 437 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 336 | (insert ,local-vars) | 438 | (insert ,local-vars) |
| @@ -371,6 +473,7 @@ | |||
| 371 | ;; Do nothing at all when a file-local mode is used. | 473 | ;; Do nothing at all when a file-local mode is used. |
| 372 | (setq-default so-long-file-local-mode-function 'so-long-inhibit) | 474 | (setq-default so-long-file-local-mode-function 'so-long-inhibit) |
| 373 | (with-temp-buffer | 475 | (with-temp-buffer |
| 476 | (display-buffer (current-buffer)) | ||
| 374 | ;; Remember the new-buffer state. The other cases will | 477 | ;; Remember the new-buffer state. The other cases will |
| 375 | ;; validate the 'reverted' state against this. | 478 | ;; validate the 'reverted' state against this. |
| 376 | (so-long-tests-remember) | 479 | (so-long-tests-remember) |
| @@ -382,6 +485,7 @@ | |||
| 382 | ;; Downgrade from major mode to minor mode. | 485 | ;; Downgrade from major mode to minor mode. |
| 383 | (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade) | 486 | (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade) |
| 384 | (with-temp-buffer | 487 | (with-temp-buffer |
| 488 | (display-buffer (current-buffer)) | ||
| 385 | (insert ,prop-line) | 489 | (insert ,prop-line) |
| 386 | (insert (make-string (1+ so-long-threshold) ?x)) | 490 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 387 | (insert ,local-vars) | 491 | (insert ,local-vars) |
| @@ -390,6 +494,7 @@ | |||
| 390 | ;; Do not treat the file-local mode specially. | 494 | ;; Do not treat the file-local mode specially. |
| 391 | (setq-default so-long-file-local-mode-function nil) | 495 | (setq-default so-long-file-local-mode-function nil) |
| 392 | (with-temp-buffer | 496 | (with-temp-buffer |
| 497 | (display-buffer (current-buffer)) | ||
| 393 | (insert ,prop-line) | 498 | (insert ,prop-line) |
| 394 | (insert (make-string (1+ so-long-threshold) ?x)) | 499 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 395 | (insert ,local-vars) | 500 | (insert ,local-vars) |
| @@ -399,6 +504,7 @@ | |||
| 399 | (setq-default so-long-file-local-mode-function | 504 | (setq-default so-long-file-local-mode-function |
| 400 | #'so-long-tests-file-local-mode-function) | 505 | #'so-long-tests-file-local-mode-function) |
| 401 | (with-temp-buffer | 506 | (with-temp-buffer |
| 507 | (display-buffer (current-buffer)) | ||
| 402 | (insert ,prop-line) | 508 | (insert ,prop-line) |
| 403 | (insert (make-string (1+ so-long-threshold) ?x)) | 509 | (insert (make-string (1+ so-long-threshold) ?x)) |
| 404 | (insert ,local-vars) | 510 | (insert ,local-vars) |
diff --git a/test/lisp/so-long-tests/spelling-tests.el b/test/lisp/so-long-tests/spelling-tests.el new file mode 100644 index 00000000000..d5bae1ef0ce --- /dev/null +++ b/test/lisp/so-long-tests/spelling-tests.el | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | ;;; spelling-tests.el --- Test suite for so-long.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Phil Sainty <psainty@orcon.net.nz> | ||
| 6 | ;; Keywords: convenience | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'ert) | ||
| 26 | (require 'ispell) | ||
| 27 | (require 'cl-lib) | ||
| 28 | |||
| 29 | ;; This test is tagged as :unstable on the basis that there may be | ||
| 30 | ;; inconsistencies between spell-checking facilities on different | ||
| 31 | ;; systems, which may cause the test to be unreliable in practice. | ||
| 32 | ;; As such the Emacs test Makefile will skip it by default, but you | ||
| 33 | ;; can run it manually with: | ||
| 34 | ;; | ||
| 35 | ;; make lisp/so-long-tests/spelling-tests SELECTOR=t | ||
| 36 | |||
| 37 | ;; Only define the test if spell-checking is possible. | ||
| 38 | (when (and ispell-program-name | ||
| 39 | (executable-find ispell-program-name) | ||
| 40 | (condition-case () | ||
| 41 | (progn (ispell-check-version) t) | ||
| 42 | (error nil)) | ||
| 43 | (member "british" (ispell-valid-dictionary-list))) | ||
| 44 | (ert-deftest so-long-spelling () | ||
| 45 | "Check the spelling in the source code." | ||
| 46 | :tags '(:unstable) ;; It works for me, but I'm not sure about others. | ||
| 47 | ;; There could be different "british" dictionaries yielding different | ||
| 48 | ;; results, for instance. | ||
| 49 | ;; | ||
| 50 | ;; The Emacs test Makefile's use of HOME=/nonexistent triggers an error | ||
| 51 | ;; when starting the inferior ispell process, so we set HOME to a valid | ||
| 52 | ;; (but empty) temporary directory for this test. | ||
| 53 | (let* ((tmpdir (make-temp-file "so-long." :dir ".ispell")) | ||
| 54 | (process-environment (cons (format "HOME=%s" tmpdir) | ||
| 55 | process-environment)) | ||
| 56 | (find-spelling-mistake | ||
| 57 | (unwind-protect | ||
| 58 | (cl-letf (((symbol-function 'ispell-command-loop) | ||
| 59 | (lambda (_miss _guess word _start _end) | ||
| 60 | (message "Unrecognised word: %s." word) | ||
| 61 | (throw 'mistake t)))) | ||
| 62 | (catch 'mistake | ||
| 63 | (find-library "so-long") | ||
| 64 | (ispell-buffer) | ||
| 65 | nil)) | ||
| 66 | (delete-directory tmpdir)))) | ||
| 67 | (should (not find-spelling-mistake))))) | ||
| 68 | |||
| 69 | ;;; spelling-tests.el ends here | ||