47855
|
1 ;;; cus-test.el --- tests for custom types and load problems
|
47801
|
2
|
106815
|
3 ;; Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
75348
|
4 ;; Free Software Foundation, Inc.
|
47801
|
5
|
|
6 ;; Author: Markus Rost <markus.rost@mathematik.uni-regensburg.de>
|
|
7 ;; Maintainer: Markus Rost <rost@math.ohio-state.edu>
|
|
8 ;; Created: 13 Sep 1998
|
|
9 ;; Keywords: maint
|
|
10
|
|
11 ;; This file is part of GNU Emacs.
|
|
12
|
94833
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
|
47801
|
14 ;; it under the terms of the GNU General Public License as published by
|
94833
|
15 ;; the Free Software Foundation, either version 3 of the License, or
|
|
16 ;; (at your option) any later version.
|
47801
|
17
|
|
18 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ;; GNU General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
94833
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
47801
|
25
|
|
26 ;;; Commentary:
|
|
27
|
47855
|
28 ;; This file provides simple tests to detect custom options with
|
|
29 ;; incorrect customization types and load problems for custom and
|
|
30 ;; autoload dependencies.
|
|
31 ;;
|
|
32 ;; The basic tests can be run in batch mode. Invoke them with
|
|
33 ;;
|
|
34 ;; src/emacs -batch -l admin/cus-test.el -f cus-test-opts
|
47801
|
35 ;;
|
47855
|
36 ;; src/emacs -batch -l admin/cus-test.el -f cus-test-deps
|
|
37 ;;
|
|
38 ;; src/emacs -batch -l admin/cus-test.el -f cus-test-libs
|
|
39 ;;
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
40 ;; src/emacs -batch -l admin/cus-test.el -f cus-test-noloads
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
41 ;;
|
47855
|
42 ;; in the emacs source directory.
|
|
43 ;;
|
|
44 ;; For interactive use: Load this file. Then
|
47801
|
45 ;;
|
|
46 ;; M-x cus-test-apropos REGEXP RET
|
|
47 ;;
|
|
48 ;; checks the options matching REGEXP. In particular
|
|
49 ;;
|
|
50 ;; M-x cus-test-apropos RET
|
|
51 ;;
|
|
52 ;; checks all options. The detected options are stored in the
|
|
53 ;; variable `cus-test-errors'.
|
|
54 ;;
|
|
55 ;; Only those options are checked which have been already loaded.
|
|
56 ;; Therefore `cus-test-apropos' is more efficient after loading many
|
|
57 ;; libraries.
|
|
58 ;;
|
47855
|
59 ;; M-x cus-test-load-custom-loads
|
|
60 ;;
|
|
61 ;; loads all (!) custom dependencies and
|
47801
|
62 ;;
|
47855
|
63 ;; M-x cus-test-load-libs
|
|
64 ;;
|
|
65 ;; loads all (!) libraries with autoloads.
|
47801
|
66 ;;
|
47815
|
67 ;; Options with a custom-get property, usually defined by a :get
|
|
68 ;; declaration, are stored in the variable
|
|
69 ;;
|
|
70 ;; `cus-test-vars-with-custom-get'
|
|
71 ;;
|
|
72 ;; Options with a state of 'changed ("changed outside the customize
|
|
73 ;; buffer") are stored in the variable
|
47801
|
74 ;;
|
47815
|
75 ;; `cus-test-vars-with-changed-state'
|
|
76 ;;
|
|
77 ;; These lists are prepared just in case one wants to investigate
|
|
78 ;; those options further.
|
|
79 ;;
|
47855
|
80 ;; The command `cus-test-opts' tests many (all?) custom options.
|
47833
|
81 ;;
|
47855
|
82 ;; The command `cus-test-deps' is like `cus-test-load-custom-loads'
|
|
83 ;; but reports about load errors.
|
47833
|
84 ;;
|
47855
|
85 ;; The command `cus-test-libs' runs for all libraries with autoloads
|
|
86 ;; separate emacs processes of the form "emacs -batch -l LIB".
|
47815
|
87 ;;
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
88 ;; The command `cus-test-noloads' returns a list of variables which
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
89 ;; are somewhere declared as custom options, but not loaded by
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
90 ;; `custom-load-symbol'.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
91 ;;
|
47855
|
92 ;; Some results from October 2002:
|
47833
|
93 ;;
|
47855
|
94 ;; 4523 options tested
|
47815
|
95 ;; The following variables might have problems:
|
47855
|
96 ;; ps-mule-font-info-database-default
|
47884
|
97 ;; grep-tree-command
|
|
98 ;; grep-find-command
|
47855
|
99 ;;
|
|
100 ;; 288 features required
|
|
101 ;; 10 files loaded
|
47833
|
102 ;; The following load problems appeared:
|
47884
|
103 ;; (killing x-win (file-error Cannot open load file x-win))
|
47855
|
104 ;; Symbol faces has loaddefs as custom dependency
|
47858
|
105 ;; (reftex-index-support reftex-vars (void-function reftex-set-dirty))
|
|
106 ;; (eshell-script em-script (void-variable eshell-directory-name))
|
|
107 ;; (pcomplete em-cmpl (void-function eshell-under-windows-p))
|
|
108 ;; (eshell-ext esh-ext (void-function eshell-under-windows-p))
|
47855
|
109 ;; ...
|
|
110 ;;
|
|
111 ;; 422 libraries had no load errors
|
|
112 ;; The following load problems appeared:
|
|
113 ;; (eudc-export error 255)
|
47858
|
114 ;; (ada-xref error 255)
|
|
115 ;; (ada-stmt error 255)
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
116 ;;
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
117 ;; The following options were not loaded by custom-load-symbol:
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
118 ;; edt-bottom-scroll-margin
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
119 ;; edt-keep-current-page-delimiter
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
120 ;; edt-top-scroll-margin
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
121 ;; edt-use-EDT-control-key-bindings
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
122 ;; edt-word-entities
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
123 ;; grep-find-use-xargs
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
124 ;; master-mode-hook
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
125 ;; outline-level
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
126 ;; outline-minor-mode-hook
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
127 ;; refill-mode-hook
|
47833
|
128
|
47889
|
129
|
47801
|
130 ;;; Code:
|
|
131
|
47855
|
132 ;;; Workarounds. For a smooth run and to avoid some side effects.
|
47801
|
133
|
47815
|
134 (defvar cus-test-after-load-libs-hook nil
|
47855
|
135 "Used to switch off undesired side effects of loading libraries.")
|
47801
|
136
|
47855
|
137 (defvar cus-test-skip-list nil
|
|
138 "List of variables to disregard by `cus-test-apropos'.")
|
|
139
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
140 (defvar cus-test-libs-noloads nil
|
47855
|
141 "List of libraries not to load by `cus-test-load-libs'.")
|
47801
|
142
|
47855
|
143 ;; The file eudc-export.el loads libraries "bbdb" and "bbdb-com" which
|
|
144 ;; are not part of GNU Emacs: (locate-library "bbdb") => nil
|
|
145 ;; We avoid the resulting errors from loading eudc-export.el:
|
|
146 (provide 'bbdb)
|
|
147 (provide 'bbdb-com)
|
47801
|
148
|
47855
|
149 ;; This avoids a hang of `cus-test-apropos' in 21.2.
|
|
150 ;; (add-to-list 'cus-test-skip-list 'sh-alias-alist)
|
|
151
|
47833
|
152 ;; Loading dunnet in batch mode leads to a Dead end.
|
47855
|
153 (let (noninteractive) (load "dunnet"))
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
154 (add-to-list 'cus-test-libs-noloads "dunnet")
|
47833
|
155
|
47855
|
156 ;; Never Viperize.
|
|
157 (setq viper-mode nil)
|
47801
|
158
|
47833
|
159 ;; Don't create a file `save-place-file'.
|
47801
|
160 (eval-after-load "saveplace"
|
|
161 '(remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
|
|
162
|
47833
|
163 ;; Don't create a file `abbrev-file-name'.
|
47801
|
164 (setq save-abbrevs nil)
|
|
165
|
|
166 ;; Avoid compile logs from adviced functions.
|
|
167 (eval-after-load "bytecomp"
|
|
168 '(setq ad-default-compilation-action 'never))
|
|
169
|
47855
|
170
|
|
171 ;;; Main code:
|
|
172
|
47801
|
173 ;; We want to log all messages.
|
|
174 (setq message-log-max t)
|
|
175
|
47833
|
176 (require 'cus-edit)
|
|
177 (require 'cus-load)
|
|
178
|
47801
|
179 (defvar cus-test-errors nil
|
|
180 "List of problematic variables found by `cus-test-apropos'.")
|
|
181
|
47855
|
182 (defvar cus-test-tested-variables nil
|
|
183 "List of options tested by last call of `cus-test-apropos'.")
|
|
184
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
185 ;; I haven't understood this :get stuff. The symbols with a
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
186 ;; custom-get property are stored here.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
187 (defvar cus-test-vars-with-custom-get nil
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
188 "Set by `cus-test-apropos' to a list of options with :get property.")
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
189
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
190 (defvar cus-test-vars-with-changed-state nil
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
191 "Set by `cus-test-apropos' to a list of options with state 'changed.")
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
192
|
47833
|
193 (defvar cus-test-deps-errors nil
|
|
194 "List of require/load problems found by `cus-test-deps'.")
|
|
195
|
47855
|
196 (defvar cus-test-deps-required nil
|
|
197 "List of dependencies required by `cus-test-deps'.
|
|
198 Only unloaded features will be require'd.")
|
|
199
|
47835
|
200 (defvar cus-test-deps-loaded nil
|
47855
|
201 "List of dependencies loaded by `cus-test-deps'.")
|
47833
|
202
|
|
203 (defvar cus-test-libs-errors nil
|
47855
|
204 "List of load problems found by `cus-test-load-libs' or `cus-test-libs'.")
|
47833
|
205
|
|
206 (defvar cus-test-libs-loaded nil
|
47855
|
207 "List of files loaded by `cus-test-load-libs' or `cus-test-libs'.")
|
47833
|
208
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
209 (defvar cus-test-vars-not-cus-loaded nil
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
210 "A list of options not loaded by `custom-load-symbol'.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
211 Set by `cus-test-noloads'.")
|
47801
|
212
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
213 ;; (defvar cus-test-vars-cus-loaded nil
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
214 ;; "A list of options loaded by `custom-load-symbol'.")
|
47815
|
215
|
47801
|
216 (defun cus-test-apropos (regexp)
|
|
217 "Check the options matching REGEXP.
|
|
218 The detected problematic options are stored in `cus-test-errors'."
|
|
219 (interactive "sVariable regexp: ")
|
|
220 (setq cus-test-errors nil)
|
|
221 (setq cus-test-tested-variables nil)
|
47855
|
222 (mapc
|
47801
|
223 (lambda (symbol)
|
|
224 (push symbol cus-test-tested-variables)
|
47855
|
225 ;; Be verbose in case we hang.
|
|
226 (message "Cus Test running...%s %s"
|
|
227 (length cus-test-tested-variables) symbol)
|
47801
|
228 (condition-case alpha
|
|
229 (let* ((type (custom-variable-type symbol))
|
|
230 (conv (widget-convert type))
|
|
231 (get (or (get symbol 'custom-get) 'default-value))
|
|
232 values
|
|
233 mismatch)
|
|
234 (when (default-boundp symbol)
|
47833
|
235 (push (funcall get symbol) values)
|
|
236 (push (eval (car (get symbol 'standard-value))) values))
|
47801
|
237 (if (boundp symbol)
|
47833
|
238 (push (symbol-value symbol) values))
|
47801
|
239 ;; That does not work.
|
47833
|
240 ;; (push (widget-get conv :value) values)
|
47801
|
241
|
|
242 ;; Check the values
|
47855
|
243 (mapc (lambda (value)
|
|
244 (unless (widget-apply conv :match value)
|
|
245 (setq mismatch 'mismatch)))
|
|
246 values)
|
47801
|
247
|
47833
|
248 ;; Store symbols with a custom-get property.
|
|
249 (when (get symbol 'custom-get)
|
47886
|
250 (add-to-list 'cus-test-vars-with-custom-get symbol))
|
47833
|
251
|
47801
|
252 ;; Changed outside the customize buffer?
|
47815
|
253 ;; This routine is not very much tested.
|
|
254 (let ((c-value
|
|
255 (or (get symbol 'customized-value)
|
|
256 (get symbol 'saved-value)
|
|
257 (get symbol 'standard-value))))
|
|
258 (and (consp c-value)
|
|
259 (boundp symbol)
|
|
260 (not (equal (eval (car c-value)) (symbol-value symbol)))
|
47886
|
261 (add-to-list 'cus-test-vars-with-changed-state symbol)))
|
47801
|
262
|
|
263 (if mismatch
|
47833
|
264 (push symbol cus-test-errors)))
|
47801
|
265
|
|
266 (error
|
47833
|
267 (push symbol cus-test-errors)
|
|
268 (message "Error for %s: %s" symbol alpha))))
|
47801
|
269 (cus-test-get-options regexp))
|
47855
|
270 (message "%s options tested"
|
47801
|
271 (length cus-test-tested-variables))
|
47833
|
272 (cus-test-errors-display))
|
47801
|
273
|
|
274 (defun cus-test-get-options (regexp)
|
|
275 "Return a list of custom options matching REGEXP."
|
|
276 (let (found)
|
|
277 (mapatoms
|
|
278 (lambda (symbol)
|
|
279 (and
|
|
280 (or
|
|
281 ;; (user-variable-p symbol)
|
|
282 (get symbol 'standard-value)
|
|
283 ;; (get symbol 'saved-value)
|
|
284 (get symbol 'custom-type))
|
|
285 (string-match regexp (symbol-name symbol))
|
47855
|
286 (not (member symbol cus-test-skip-list))
|
47801
|
287 (push symbol found))))
|
|
288 found))
|
|
289
|
|
290 (defun cus-test-errors-display ()
|
|
291 "Report about the errors found by cus-test."
|
|
292 (with-output-to-temp-buffer "*cus-test-errors*"
|
|
293 (set-buffer standard-output)
|
|
294 (insert (format "Cus Test tested %s variables.\
|
|
295 See `cus-test-tested-variables'.\n\n"
|
|
296 (length cus-test-tested-variables)))
|
47855
|
297 (if (not cus-test-errors)
|
|
298 (insert "No errors found by cus-test.")
|
|
299 (insert "The following variables seem to have problems:\n\n")
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
300 (dolist (e cus-test-errors)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
301 (insert (symbol-name e) "\n")))))
|
47801
|
302
|
47855
|
303 (defun cus-test-load-custom-loads ()
|
47801
|
304 "Call `custom-load-symbol' on all atoms."
|
|
305 (interactive)
|
|
306 (mapatoms 'custom-load-symbol)
|
47815
|
307 (run-hooks 'cus-test-after-load-libs-hook))
|
47801
|
308
|
47855
|
309 (defun cus-test-load-libs ()
|
|
310 "Load the libraries with autoloads.
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
311 Don't load libraries in `cus-test-libs-noloads'."
|
47855
|
312 (interactive)
|
|
313 (setq cus-test-libs-errors nil)
|
|
314 (setq cus-test-libs-loaded nil)
|
|
315 (mapc
|
|
316 (lambda (file)
|
|
317 (condition-case alpha
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
318 (unless (member file cus-test-libs-noloads)
|
47855
|
319 (load file)
|
|
320 (push file cus-test-libs-loaded))
|
|
321 (error
|
|
322 (push (cons file alpha) cus-test-libs-errors)
|
|
323 (message "Error for %s: %s" file alpha))))
|
|
324 (cus-test-get-autoload-deps))
|
|
325 (message "%s libraries loaded successfully"
|
|
326 (length cus-test-libs-loaded))
|
|
327 (if (not cus-test-libs-errors)
|
|
328 (message "No load problems encountered")
|
|
329 (message "The following load problems appeared:")
|
|
330 (cus-test-message cus-test-libs-errors))
|
|
331 (run-hooks 'cus-test-after-load-libs-hook))
|
|
332
|
|
333 (defun cus-test-get-autoload-deps ()
|
|
334 "Return the list of libraries with autoloads."
|
|
335 (with-temp-buffer
|
|
336 (insert-file-contents (locate-library "loaddefs"))
|
|
337 ;; This is from `customize-option'.
|
|
338 (let (deps file)
|
|
339 (while
|
|
340 (search-forward "\n;;; Generated autoloads from " nil t)
|
|
341 (goto-char (match-end 0))
|
|
342 (setq file (buffer-substring (point)
|
|
343 (progn (end-of-line) (point))))
|
|
344 (setq file (file-name-nondirectory file))
|
|
345 (string-match "\\.el\\'" file)
|
|
346 (setq file (substring file 0 (match-beginning 0)))
|
|
347 (setq deps (nconc deps (list file))))
|
|
348 deps)))
|
|
349
|
|
350 (defun cus-test-message (list)
|
|
351 "Print the members of LIST line by line."
|
|
352 (dolist (m list) (message "%s" m)))
|
|
353
|
|
354
|
47833
|
355 ;;; The routines for batch mode:
|
|
356
|
47855
|
357 (defun cus-test-opts ()
|
47833
|
358 "Test custom options.
|
|
359 This function is suitable for batch mode. E.g., invoke
|
|
360
|
|
361 src/emacs -batch -l admin/cus-test.el -f cus-test-opts
|
|
362
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
363 in the Emacs source directory."
|
47833
|
364 (interactive)
|
47884
|
365 (message "Running %s" 'cus-test-load-libs)
|
|
366 (cus-test-load-libs)
|
47833
|
367 (message "Running %s" 'cus-test-load-custom-loads)
|
|
368 (cus-test-load-custom-loads)
|
|
369 (message "Running %s" 'cus-test-apropos)
|
|
370 (cus-test-apropos "")
|
47855
|
371 (if (not cus-test-errors)
|
|
372 (message "No problems found")
|
|
373 (message "The following options might have problems:")
|
|
374 (cus-test-message cus-test-errors)))
|
47833
|
375
|
47855
|
376 (defun cus-test-deps ()
|
47833
|
377 "Run a verbose version of `custom-load-symbol' on all atoms.
|
|
378 This function is suitable for batch mode. E.g., invoke
|
|
379
|
|
380 src/emacs -batch -l admin/cus-test.el -f cus-test-deps
|
|
381
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
382 in the Emacs source directory."
|
47833
|
383 (interactive)
|
|
384 (setq cus-test-deps-errors nil)
|
47855
|
385 (setq cus-test-deps-required nil)
|
47835
|
386 (setq cus-test-deps-loaded nil)
|
47833
|
387 (mapatoms
|
|
388 ;; This code is mainly from `custom-load-symbol'.
|
|
389 (lambda (symbol)
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
390 (let ((custom-load-recursion t))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
391 (dolist (load (get symbol 'custom-loads))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
392 (cond
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
393 ((symbolp load)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
394 ;; (condition-case nil (require load) (error nil))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
395 (condition-case alpha
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
396 (unless (featurep load)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
397 (require load)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
398 (push (list symbol load) cus-test-deps-required))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
399 (error
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
400 (push (list symbol load alpha) cus-test-deps-errors)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
401 (message "Require problem: %s %s %s" symbol load alpha))))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
402 ((equal load "loaddefs")
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
403 (push
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
404 (message "Symbol %s has loaddefs as custom dependency" symbol)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
405 cus-test-deps-errors))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
406 ;; This is subsumed by the test below, but it's much
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
407 ;; faster.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
408 ((assoc load load-history))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
409 ;; This was just
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
410 ;; (assoc (locate-library load) load-history)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
411 ;; but has been optimized not to load locate-library
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
412 ;; if not necessary.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
413 ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
414 "\\(\\'\\|\\.\\)"))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
415 (found nil))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
416 (dolist (loaded load-history)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
417 (and (stringp (car loaded))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
418 (string-match regexp (car loaded))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
419 (setq found t)))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
420 found))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
421 ;; Without this, we would load cus-edit recursively.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
422 ;; We are still loading it when we call this,
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
423 ;; and it is not in load-history yet.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
424 ((equal load "cus-edit"))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
425 ;; This would ignore load problems with files in
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
426 ;; lisp/term/
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
427 ;; ((locate-library (concat term-file-prefix load)))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
428 (t
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
429 ;; (condition-case nil (load load) (error nil))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
430 (condition-case alpha
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
431 (progn
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
432 (load load)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
433 (push (list symbol load) cus-test-deps-loaded))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
434 (error
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
435 (push (list symbol load alpha) cus-test-deps-errors)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
436 (message "Load Problem: %s %s %s" symbol load alpha))))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
437 )))))
|
47855
|
438 (message "%s features required"
|
|
439 (length cus-test-deps-required))
|
|
440 (message "%s files loaded"
|
47835
|
441 (length cus-test-deps-loaded))
|
47855
|
442 (if (not cus-test-deps-errors)
|
|
443 (message "No load problems encountered")
|
|
444 (message "The following load problems appeared:")
|
|
445 (cus-test-message cus-test-deps-errors))
|
47833
|
446 (run-hooks 'cus-test-after-load-libs-hook))
|
|
447
|
|
448 (defun cus-test-libs ()
|
47855
|
449 "Load the libraries with autoloads in separate processes.
|
47833
|
450 This function is useful to detect load problems of libraries.
|
|
451 It is suitable for batch mode. E.g., invoke
|
47801
|
452
|
47833
|
453 src/emacs -batch -l admin/cus-test.el -f cus-test-libs
|
|
454
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
455 in the Emacs source directory."
|
47801
|
456 (interactive)
|
47855
|
457 (with-temp-buffer
|
|
458 (setq cus-test-libs-errors nil)
|
|
459 (setq cus-test-libs-loaded nil)
|
|
460 (cd source-directory)
|
|
461 (if (not (file-executable-p "src/emacs"))
|
|
462 (error "No Emacs executable in %ssrc" default-directory))
|
|
463 (mapc
|
|
464 (lambda (file)
|
|
465 (condition-case alpha
|
|
466 (let (fn cmd status)
|
|
467 (setq fn (locate-library file))
|
|
468 (if (not fn)
|
|
469 (error "Library %s not found" file))
|
|
470 (setq cmd (concat "src/emacs -batch -l " fn))
|
|
471 (setq status (call-process shell-file-name nil nil nil
|
|
472 shell-command-switch cmd))
|
47889
|
473 (if (equal status 0)
|
47855
|
474 (message "%s" file)
|
|
475 (error "%s" status))
|
|
476 (push file cus-test-libs-loaded))
|
|
477 (error
|
|
478 (push (cons file alpha) cus-test-libs-errors)
|
|
479 (message "Error for %s: %s" file alpha))))
|
|
480 (cus-test-get-autoload-deps))
|
|
481 (message "Default Directory: %s" default-directory)
|
|
482 (message "%s libraries had no load errors"
|
|
483 (length cus-test-libs-loaded))
|
|
484 (if (not cus-test-libs-errors)
|
|
485 (message "No load problems encountered")
|
|
486 (message "The following load problems appeared:")
|
|
487 (cus-test-message cus-test-libs-errors))
|
|
488 (run-hooks 'cus-test-after-load-libs-hook)))
|
47801
|
489
|
47894
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
490 (defun cus-test-noloads ()
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
491 "Find custom options not loaded by `custom-load-symbol'.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
492 Calling this function after `cus-test-load-libs' is not meaningful.
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
493 It is suitable for batch mode. E.g., invoke
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
494
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
495 src/emacs -batch -l admin/cus-test.el -f cus-test-noloads
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
496
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
497 in the Emacs source directory."
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
498 (interactive)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
499 (let (cus-loaded)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
500
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
501 (message "Running %s" 'cus-test-load-custom-loads)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
502 (cus-test-load-custom-loads)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
503 (setq cus-loaded
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
504 (cus-test-get-options ""))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
505
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
506 (message "Running %s" 'cus-test-load-libs)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
507 (cus-test-load-libs)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
508 (setq cus-test-vars-not-cus-loaded
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
509 (cus-test-get-options ""))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
510
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
511 (dolist (o cus-loaded)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
512 (setq cus-test-vars-not-cus-loaded
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
513 (delete o cus-test-vars-not-cus-loaded)))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
514
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
515 (if (not cus-test-vars-not-cus-loaded)
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
516 (message "No options not loaded by custom-load-symbol found")
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
517 (message "The following options were not loaded by custom-load-symbol:")
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
518 (cus-test-message
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
519 (sort cus-test-vars-not-cus-loaded 'string<)))))
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
520
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
521 ;; And last but not least a quiz:
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
522 ;;
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
523 ;; Evaluation of the form (customize-option 'debug-on-error) yields a
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
524 ;; *Customize* buffer with a mismatch mess. Why?
|
11b74e54eddf
Reworked. Added a new test cus-test-noloads. And a quiz.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
525
|
47801
|
526 (provide 'cus-test)
|
|
527
|
52401
|
528 ;;; arch-tag: a4991a31-548d-48fb-8ba1-1ebbe68eb2e7
|
47801
|
529 ;;; cus-test.el ends here
|