aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/so-long-tests/spelling-tests.el69
1 files changed, 69 insertions, 0 deletions
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