diff options
| author | Markus Rost | 2002-10-10 22:50:35 +0000 |
|---|---|---|
| committer | Markus Rost | 2002-10-10 22:50:35 +0000 |
| commit | 592cd48bf62b9ed3621085e4dbeef2fa10573215 (patch) | |
| tree | b08e1267ef73b45e80cb7f4e8cc24e0e1b33d256 /admin/cus-test.el | |
| parent | e3264d0caa2277459d56b56ac5f4d0ad39d22acc (diff) | |
| download | emacs-592cd48bf62b9ed3621085e4dbeef2fa10573215.tar.gz emacs-592cd48bf62b9ed3621085e4dbeef2fa10573215.zip | |
Extended and reorganized.
There are now 3 tests which can be run in batch mode.
See the Commentary section.
Diffstat (limited to 'admin/cus-test.el')
| -rw-r--r-- | admin/cus-test.el | 318 |
1 files changed, 191 insertions, 127 deletions
diff --git a/admin/cus-test.el b/admin/cus-test.el index 9280587156c..6b3c4ee1885 100644 --- a/admin/cus-test.el +++ b/admin/cus-test.el | |||
| @@ -29,7 +29,8 @@ | |||
| 29 | ;; Some user options in GNU Emacs have been defined with incorrect | 29 | ;; Some user options in GNU Emacs have been defined with incorrect |
| 30 | ;; customization types. As a result the customization of these | 30 | ;; customization types. As a result the customization of these |
| 31 | ;; options is disabled. This file provides functions to detect such | 31 | ;; options is disabled. This file provides functions to detect such |
| 32 | ;; options. | 32 | ;; options. It contains also simple tests for loading libraries and |
| 33 | ;; custom dependencies. | ||
| 33 | ;; | 34 | ;; |
| 34 | ;; Usage: Load this file. Then | 35 | ;; Usage: Load this file. Then |
| 35 | ;; | 36 | ;; |
| @@ -46,33 +47,10 @@ | |||
| 46 | ;; Therefore `cus-test-apropos' is more efficient after loading many | 47 | ;; Therefore `cus-test-apropos' is more efficient after loading many |
| 47 | ;; libraries. | 48 | ;; libraries. |
| 48 | ;; | 49 | ;; |
| 49 | ;; M-x cus-test-library LIB RET | ||
| 50 | ;; | ||
| 51 | ;; loads library LIB and checks the options matching LIB. | ||
| 52 | ;; | ||
| 53 | ;; M-x cus-test-load-custom-loads RET | 50 | ;; M-x cus-test-load-custom-loads RET |
| 54 | ;; | 51 | ;; |
| 55 | ;; loads all (!) custom dependencies. | 52 | ;; loads all (!) custom dependencies. |
| 56 | ;; | 53 | ;; |
| 57 | ;; M-x cus-test-load-libs RET | ||
| 58 | ;; | ||
| 59 | ;; loads all (!) libraries with autoloads. This function is useful to | ||
| 60 | ;; detect load problems of libraries. | ||
| 61 | ;; | ||
| 62 | ;; For a maximal test of custom options invoke | ||
| 63 | ;; | ||
| 64 | ;; M-x cus-test-all | ||
| 65 | ;; | ||
| 66 | ;; This function is suitable for batch mode. E.g., invoke | ||
| 67 | ;; | ||
| 68 | ;; src/emacs -batch -l admin/cus-test.el -f cus-test-all | ||
| 69 | ;; | ||
| 70 | ;; in the emacs source directory. | ||
| 71 | ;; | ||
| 72 | ;; To make cus-test work one has usually to work-around some existing | ||
| 73 | ;; bugs/problems. Therefore this file contains a "Workaround" | ||
| 74 | ;; section, to be edited once in a while. | ||
| 75 | ;; | ||
| 76 | ;; Options with a custom-get property, usually defined by a :get | 54 | ;; Options with a custom-get property, usually defined by a :get |
| 77 | ;; declaration, are stored in the variable | 55 | ;; declaration, are stored in the variable |
| 78 | ;; | 56 | ;; |
| @@ -86,48 +64,52 @@ | |||
| 86 | ;; These lists are prepared just in case one wants to investigate | 64 | ;; These lists are prepared just in case one wants to investigate |
| 87 | ;; those options further. | 65 | ;; those options further. |
| 88 | ;; | 66 | ;; |
| 89 | ;; Current result (Oct 6, 2002) of cus-test-all: | 67 | ;; For a maximal test of custom options invoke |
| 90 | ;; | 68 | ;; |
| 91 | ;; Cus Test tested 4514 variables. | 69 | ;; M-x cus-test-opts |
| 70 | ;; | ||
| 71 | ;; Other test routines are `cus-test-deps' and `cus-test-libs'. | ||
| 72 | ;; These functions are suitable for batch mode. Invoke them with | ||
| 73 | ;; | ||
| 74 | ;; src/emacs -batch -l admin/cus-test.el -f cus-test-opts | ||
| 75 | ;; | ||
| 76 | ;; src/emacs -batch -l admin/cus-test.el -f cus-test-deps | ||
| 77 | ;; | ||
| 78 | ;; src/emacs -batch -l admin/cus-test.el -f cus-test-libs | ||
| 79 | ;; | ||
| 80 | ;; in the emacs source directory. | ||
| 81 | ;; | ||
| 82 | ;; To make cus-test work one has usually to work-around some existing | ||
| 83 | ;; bugs/problems. Therefore this file contains "Fixme" and | ||
| 84 | ;; "Workarounds" sections, to be edited once in a while. | ||
| 85 | ;; | ||
| 86 | ;; Results from Oct 10, 2002: | ||
| 87 | ;; | ||
| 88 | ;; Cus Test tested 4514 options. | ||
| 92 | ;; The following variables might have problems: | 89 | ;; The following variables might have problems: |
| 93 | ;; (ps-mule-font-info-database-default) | 90 | ;; (ps-mule-font-info-database-default) |
| 94 | 91 | ||
| 95 | ;;; Code: | 92 | ;; Cus Test Deps loaded 332 files. |
| 93 | ;; The following load problems appeared: | ||
| 94 | ;; ((killing x-win (file-error Cannot open load file x-win))) | ||
| 96 | 95 | ||
| 97 | ;;; User variables: | 96 | ;; Cus Test Libs loaded 424 files. |
| 97 | ;; No load problems encountered by Cus Test Libs | ||
| 98 | 98 | ||
| 99 | (defvar cus-test-strange-vars nil | 99 | ;;; Code: |
| 100 | "*List of variables to disregard by `cus-test-apropos'.") | ||
| 101 | 100 | ||
| 102 | (defvar cus-test-strange-libs nil | 101 | ;;; Variables for workarounds: |
| 103 | "*List of libraries to avoid by `cus-test-load-libs'.") | ||
| 104 | 102 | ||
| 105 | (defvar cus-test-after-load-libs-hook nil | 103 | (defvar cus-test-after-load-libs-hook nil |
| 106 | "*Hook to repair the worst side effects of loading buggy libraries. | 104 | "Hook to repair the worst side effects of loading buggy libraries.") |
| 107 | It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'") | ||
| 108 | |||
| 109 | ;;; Workarounds: | ||
| 110 | |||
| 111 | ;; The file eudc-export.el loads libraries "bbdb" and "bbdb-com" which | ||
| 112 | ;; are not part of GNU Emacs. | ||
| 113 | (provide 'bbdb) | ||
| 114 | (provide 'bbdb-com) | ||
| 115 | ;; (locate-library "bbdb") | ||
| 116 | |||
| 117 | ;; reftex must be loaded before reftex-vars. | ||
| 118 | (load "reftex") | ||
| 119 | 105 | ||
| 120 | ;; eshell must be loaded before em-script. eshell loads esh-util, | 106 | (defvar cus-test-libs-noloads nil |
| 121 | ;; which must be loaded before em-cmpl, em-dirs and similar libraries. | 107 | "List of libraries not to load by `cus-test-libs'.") |
| 122 | (load "eshell") | ||
| 123 | 108 | ||
| 124 | ;; Loading dunnet in batch mode leads to a dead end. | 109 | ;;; Fixme: |
| 125 | (when noninteractive | ||
| 126 | (let (noninteractive) (load "dunnet")) | ||
| 127 | (add-to-list 'cus-test-strange-libs "dunnet")) | ||
| 128 | 110 | ||
| 129 | ;; Loading filesets.el currently disables mini-buffer echoes. | 111 | ;; Loading filesets.el currently disables mini-buffer echoes. |
| 130 | ;; (add-to-list 'cus-test-strange-libs "filesets") | 112 | ;; (add-to-list 'cus-test-libs-noloads "filesets") |
| 131 | (add-hook | 113 | (add-hook |
| 132 | 'cus-test-after-load-libs-hook | 114 | 'cus-test-after-load-libs-hook |
| 133 | (lambda nil | 115 | (lambda nil |
| @@ -138,16 +120,37 @@ It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'") | |||
| 138 | )) | 120 | )) |
| 139 | ;; (setq cus-test-after-load-libs-hook nil) | 121 | ;; (setq cus-test-after-load-libs-hook nil) |
| 140 | 122 | ||
| 123 | ;; eshell must be loaded before em-script. eshell loads esh-util, | ||
| 124 | ;; which must be loaded before em-cmpl, em-dirs and similar libraries. | ||
| 125 | (load "eshell") | ||
| 126 | |||
| 127 | ;; reftex must be loaded before reftex-vars. | ||
| 128 | (load "reftex") | ||
| 129 | |||
| 130 | ;;; Workarounds: | ||
| 131 | |||
| 132 | ;; The file eudc-export.el loads libraries "bbdb" and "bbdb-com" which | ||
| 133 | ;; are not part of GNU Emacs: (locate-library "bbdb") => nil | ||
| 134 | |||
| 135 | ;; This avoids the resulting errors from loading eudc-export.el. | ||
| 136 | (provide 'bbdb) | ||
| 137 | (provide 'bbdb-com) | ||
| 138 | |||
| 139 | ;; Loading dunnet in batch mode leads to a Dead end. | ||
| 140 | (let (noninteractive) | ||
| 141 | (load "dunnet")) | ||
| 142 | (add-to-list 'cus-test-libs-noloads "dunnet") | ||
| 143 | |||
| 141 | ;;; Silencing: | 144 | ;;; Silencing: |
| 142 | 145 | ||
| 143 | ;; Don't create a file filesets-menu-cache-file. | 146 | ;; Don't create a file `filesets-menu-cache-file'. |
| 144 | (setq filesets-menu-cache-file "") | 147 | (setq filesets-menu-cache-file "") |
| 145 | 148 | ||
| 146 | ;; Don't create a file save-place-file. | 149 | ;; Don't create a file `save-place-file'. |
| 147 | (eval-after-load "saveplace" | 150 | (eval-after-load "saveplace" |
| 148 | '(remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)) | 151 | '(remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)) |
| 149 | 152 | ||
| 150 | ;; Don't create a file abbrev-file-name. | 153 | ;; Don't create a file `abbrev-file-name'. |
| 151 | (setq save-abbrevs nil) | 154 | (setq save-abbrevs nil) |
| 152 | 155 | ||
| 153 | ;; Avoid compile logs from adviced functions. | 156 | ;; Avoid compile logs from adviced functions. |
| @@ -160,12 +163,27 @@ It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'") | |||
| 160 | 163 | ||
| 161 | ;;; Main Code: | 164 | ;;; Main Code: |
| 162 | 165 | ||
| 166 | (require 'cus-edit) | ||
| 167 | (require 'cus-load) | ||
| 168 | |||
| 163 | (defvar cus-test-tested-variables nil | 169 | (defvar cus-test-tested-variables nil |
| 164 | "Options tested by last call of `cus-test-apropos'.") | 170 | "Options tested by last call of `cus-test-apropos'.") |
| 165 | 171 | ||
| 166 | (defvar cus-test-errors nil | 172 | (defvar cus-test-errors nil |
| 167 | "List of problematic variables found by `cus-test-apropos'.") | 173 | "List of problematic variables found by `cus-test-apropos'.") |
| 168 | 174 | ||
| 175 | (defvar cus-test-deps-errors nil | ||
| 176 | "List of require/load problems found by `cus-test-deps'.") | ||
| 177 | |||
| 178 | (defvar cus-test-deps-tested nil | ||
| 179 | "Dependencies loaded by `cus-test-deps'.") | ||
| 180 | |||
| 181 | (defvar cus-test-libs-errors nil | ||
| 182 | "List of load problems found by `cus-test-libs'.") | ||
| 183 | |||
| 184 | (defvar cus-test-libs-loaded nil | ||
| 185 | "Files loaded by `cus-test-libs'.") | ||
| 186 | |||
| 169 | ;; I haven't understood this :get stuff. However, there are only very | 187 | ;; I haven't understood this :get stuff. However, there are only very |
| 170 | ;; few variables with a custom-get property. Such symbols are stored | 188 | ;; few variables with a custom-get property. Such symbols are stored |
| 171 | ;; in `cus-test-vars-with-custom-get'. | 189 | ;; in `cus-test-vars-with-custom-get'. |
| @@ -175,9 +193,6 @@ It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'") | |||
| 175 | (defvar cus-test-vars-with-changed-state nil | 193 | (defvar cus-test-vars-with-changed-state nil |
| 176 | "Set by `cus-test-apropos' to a list of options with state 'changed.") | 194 | "Set by `cus-test-apropos' to a list of options with state 'changed.") |
| 177 | 195 | ||
| 178 | (require 'cus-edit) | ||
| 179 | (require 'cus-load) | ||
| 180 | |||
| 181 | (defun cus-test-apropos (regexp) | 196 | (defun cus-test-apropos (regexp) |
| 182 | "Check the options matching REGEXP. | 197 | "Check the options matching REGEXP. |
| 183 | The detected problematic options are stored in `cus-test-errors'." | 198 | The detected problematic options are stored in `cus-test-errors'." |
| @@ -193,19 +208,16 @@ The detected problematic options are stored in `cus-test-errors'." | |||
| 193 | (condition-case alpha | 208 | (condition-case alpha |
| 194 | (let* ((type (custom-variable-type symbol)) | 209 | (let* ((type (custom-variable-type symbol)) |
| 195 | (conv (widget-convert type)) | 210 | (conv (widget-convert type)) |
| 196 | ;; I haven't understood this :get stuff. | ||
| 197 | (get (or (get symbol 'custom-get) 'default-value)) | 211 | (get (or (get symbol 'custom-get) 'default-value)) |
| 198 | values | 212 | values |
| 199 | mismatch) | 213 | mismatch) |
| 200 | (when (default-boundp symbol) | 214 | (when (default-boundp symbol) |
| 201 | (add-to-list 'values | 215 | (push (funcall get symbol) values) |
| 202 | (funcall get symbol)) | 216 | (push (eval (car (get symbol 'standard-value))) values)) |
| 203 | (add-to-list 'values | ||
| 204 | (eval (car (get symbol 'standard-value))))) | ||
| 205 | (if (boundp symbol) | 217 | (if (boundp symbol) |
| 206 | (add-to-list 'values (symbol-value symbol))) | 218 | (push (symbol-value symbol) values)) |
| 207 | ;; That does not work. | 219 | ;; That does not work. |
| 208 | ;; (add-to-list 'values (widget-get conv :value)) | 220 | ;; (push (widget-get conv :value) values) |
| 209 | 221 | ||
| 210 | ;; Check the values | 222 | ;; Check the values |
| 211 | (mapcar (lambda (value) | 223 | (mapcar (lambda (value) |
| @@ -213,6 +225,10 @@ The detected problematic options are stored in `cus-test-errors'." | |||
| 213 | (setq mismatch 'mismatch))) | 225 | (setq mismatch 'mismatch))) |
| 214 | values) | 226 | values) |
| 215 | 227 | ||
| 228 | ;; Store symbols with a custom-get property. | ||
| 229 | (when (get symbol 'custom-get) | ||
| 230 | (push symbol cus-test-vars-with-custom-get)) | ||
| 231 | |||
| 216 | ;; Changed outside the customize buffer? | 232 | ;; Changed outside the customize buffer? |
| 217 | ;; This routine is not very much tested. | 233 | ;; This routine is not very much tested. |
| 218 | (let ((c-value | 234 | (let ((c-value |
| @@ -222,31 +238,18 @@ The detected problematic options are stored in `cus-test-errors'." | |||
| 222 | (and (consp c-value) | 238 | (and (consp c-value) |
| 223 | (boundp symbol) | 239 | (boundp symbol) |
| 224 | (not (equal (eval (car c-value)) (symbol-value symbol))) | 240 | (not (equal (eval (car c-value)) (symbol-value symbol))) |
| 225 | (add-to-list 'cus-test-vars-with-changed-state symbol))) | 241 | (push symbol cus-test-vars-with-changed-state))) |
| 226 | |||
| 227 | ;; Store symbols with a custom-get property. | ||
| 228 | (when (get symbol 'custom-get) | ||
| 229 | (add-to-list 'cus-test-vars-with-custom-get symbol) | ||
| 230 | ;; No need anymore to ignore them. | ||
| 231 | ;; (setq mismatch nil) | ||
| 232 | ) | ||
| 233 | 242 | ||
| 234 | (if mismatch | 243 | (if mismatch |
| 235 | (add-to-list 'cus-test-errors symbol))) | 244 | (push symbol cus-test-errors))) |
| 236 | 245 | ||
| 237 | (error | 246 | (error |
| 238 | (add-to-list 'cus-test-errors symbol) | 247 | (push symbol cus-test-errors) |
| 239 | (if (y-or-n-p | 248 | (message "Error for %s: %s" symbol alpha)))) |
| 240 | (format "Error for %s: %s\nContinue? " | ||
| 241 | symbol alpha)) | ||
| 242 | (message "Error for %s: %s" symbol alpha) | ||
| 243 | (error "Error for %s: %s" symbol alpha))))) | ||
| 244 | (cus-test-get-options regexp)) | 249 | (cus-test-get-options regexp)) |
| 245 | (message "Cus Test tested %s variables." | 250 | (message "Cus Test tested %s options." |
| 246 | (length cus-test-tested-variables)) | 251 | (length cus-test-tested-variables)) |
| 247 | ;; (describe-variable 'cus-test-errors) | 252 | (cus-test-errors-display)) |
| 248 | (cus-test-errors-display) | ||
| 249 | ) | ||
| 250 | 253 | ||
| 251 | (defun cus-test-get-options (regexp) | 254 | (defun cus-test-get-options (regexp) |
| 252 | "Return a list of custom options matching REGEXP." | 255 | "Return a list of custom options matching REGEXP." |
| @@ -260,7 +263,7 @@ The detected problematic options are stored in `cus-test-errors'." | |||
| 260 | ;; (get symbol 'saved-value) | 263 | ;; (get symbol 'saved-value) |
| 261 | (get symbol 'custom-type)) | 264 | (get symbol 'custom-type)) |
| 262 | (string-match regexp (symbol-name symbol)) | 265 | (string-match regexp (symbol-name symbol)) |
| 263 | (not (member symbol cus-test-strange-vars)) | 266 | ;; (not (member symbol cus-test-strange-vars)) |
| 264 | (push symbol found)))) | 267 | (push symbol found)))) |
| 265 | found)) | 268 | found)) |
| 266 | 269 | ||
| @@ -278,24 +281,105 @@ The detected problematic options are stored in `cus-test-errors'." | |||
| 278 | (setq L (cdr L)))) | 281 | (setq L (cdr L)))) |
| 279 | (insert "No errors found by cus-test.")))) | 282 | (insert "No errors found by cus-test.")))) |
| 280 | 283 | ||
| 281 | (defun cus-test-library (lib) | ||
| 282 | "Load library LIB and call `cus-test-apropos' on LIB." | ||
| 283 | (interactive "sTest variables in library: ") | ||
| 284 | (load-library lib) | ||
| 285 | (cus-test-apropos lib)) | ||
| 286 | |||
| 287 | (defun cus-test-load-custom-loads nil | 284 | (defun cus-test-load-custom-loads nil |
| 288 | "Call `custom-load-symbol' on all atoms." | 285 | "Call `custom-load-symbol' on all atoms." |
| 289 | (interactive) | 286 | (interactive) |
| 290 | (mapatoms 'custom-load-symbol) | 287 | (mapatoms 'custom-load-symbol) |
| 291 | (run-hooks 'cus-test-after-load-libs-hook)) | 288 | (run-hooks 'cus-test-after-load-libs-hook)) |
| 292 | 289 | ||
| 293 | (defun cus-test-load-libs () | 290 | ;;; The routines for batch mode: |
| 291 | |||
| 292 | (defun cus-test-opts nil | ||
| 293 | "Test custom options. | ||
| 294 | This function is suitable for batch mode. E.g., invoke | ||
| 295 | |||
| 296 | src/emacs -batch -l admin/cus-test.el -f cus-test-opts | ||
| 297 | |||
| 298 | in the emacs source directory." | ||
| 299 | (interactive) | ||
| 300 | (message "Running %s" 'cus-test-load-custom-loads) | ||
| 301 | (cus-test-load-custom-loads) | ||
| 302 | (message "Running %s" 'cus-test-apropos) | ||
| 303 | (cus-test-apropos "") | ||
| 304 | (if cus-test-errors | ||
| 305 | (message "The following options might have problems:\n%s" | ||
| 306 | cus-test-errors) | ||
| 307 | (message "No problems found by Cus Test Opts"))) | ||
| 308 | |||
| 309 | (defun cus-test-deps nil | ||
| 310 | "Run a verbose version of `custom-load-symbol' on all atoms. | ||
| 311 | This function is suitable for batch mode. E.g., invoke | ||
| 312 | |||
| 313 | src/emacs -batch -l admin/cus-test.el -f cus-test-deps | ||
| 314 | |||
| 315 | in the emacs source directory." | ||
| 316 | (interactive) | ||
| 317 | (setq cus-test-deps-errors nil) | ||
| 318 | (setq cus-test-deps-tested nil) | ||
| 319 | (mapatoms | ||
| 320 | ;; This code is mainly from `custom-load-symbol'. | ||
| 321 | (lambda (symbol) | ||
| 322 | (unless custom-load-recursion | ||
| 323 | (let ((custom-load-recursion t)) | ||
| 324 | (dolist (load (get symbol 'custom-loads)) | ||
| 325 | (cond | ||
| 326 | ((symbolp load) | ||
| 327 | ;; (condition-case nil (require load) (error nil)) | ||
| 328 | (condition-case alpha | ||
| 329 | (require load) | ||
| 330 | (error | ||
| 331 | (push (list symbol load alpha) cus-test-deps-errors) | ||
| 332 | (message "Require problem: %s %s: %s" symbol load alpha))) | ||
| 333 | (push (list symbol load) cus-test-deps-tested)) | ||
| 334 | ;; This is subsumed by the test below, but it's much | ||
| 335 | ;; faster. | ||
| 336 | ((assoc load load-history)) | ||
| 337 | ;; This was just | ||
| 338 | ;; (assoc (locate-library load) load-history) | ||
| 339 | ;; but has been optimized not to load locate-library | ||
| 340 | ;; if not necessary. | ||
| 341 | ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load) | ||
| 342 | "\\(\\'\\|\\.\\)")) | ||
| 343 | (found nil)) | ||
| 344 | (dolist (loaded load-history) | ||
| 345 | (and (stringp (car loaded)) | ||
| 346 | (string-match regexp (car loaded)) | ||
| 347 | (setq found t))) | ||
| 348 | found)) | ||
| 349 | ;; Without this, we would load cus-edit recursively. | ||
| 350 | ;; We are still loading it when we call this, | ||
| 351 | ;; and it is not in load-history yet. | ||
| 352 | ((equal load "cus-edit")) | ||
| 353 | (t | ||
| 354 | ;; (condition-case nil (load load) (error nil)) | ||
| 355 | (condition-case alpha | ||
| 356 | (load load) | ||
| 357 | (error | ||
| 358 | (push (list symbol load alpha) cus-test-deps-errors) | ||
| 359 | (message "Load Problem: %s %s: %s" symbol load alpha))) | ||
| 360 | (push (list symbol load) cus-test-deps-tested)) | ||
| 361 | )))))) | ||
| 362 | (message "Cus Test Deps loaded %s files." | ||
| 363 | (length cus-test-deps-tested)) | ||
| 364 | (if cus-test-deps-errors | ||
| 365 | (message "The following load problems appeared:\n%s" | ||
| 366 | cus-test-deps-errors) | ||
| 367 | (message "No load problems encountered by Cus Test Deps")) | ||
| 368 | (run-hooks 'cus-test-after-load-libs-hook)) | ||
| 369 | |||
| 370 | (defun cus-test-libs () | ||
| 294 | "Load the libraries with autoloads in loaddefs.el. | 371 | "Load the libraries with autoloads in loaddefs.el. |
| 295 | Don't load libraries in `cus-test-strange-libs'. | 372 | Don't load libraries in `cus-test-libs-noloads'. |
| 296 | 373 | ||
| 297 | This function is useful to detect load problems of libraries." | 374 | This function is useful to detect load problems of libraries. |
| 375 | It is suitable for batch mode. E.g., invoke | ||
| 376 | |||
| 377 | src/emacs -batch -l admin/cus-test.el -f cus-test-libs | ||
| 378 | |||
| 379 | in the emacs source directory." | ||
| 298 | (interactive) | 380 | (interactive) |
| 381 | (setq cus-test-libs-errors nil) | ||
| 382 | (setq cus-test-libs-loaded nil) | ||
| 299 | (set-buffer (find-file-noselect (locate-library "loaddefs"))) | 383 | (set-buffer (find-file-noselect (locate-library "loaddefs"))) |
| 300 | (goto-char (point-min)) | 384 | (goto-char (point-min)) |
| 301 | (let (file) | 385 | (let (file) |
| @@ -310,40 +394,20 @@ This function is useful to detect load problems of libraries." | |||
| 310 | (when (string-match "\\.el\\'" file) | 394 | (when (string-match "\\.el\\'" file) |
| 311 | (setq file (substring file 0 (match-beginning 0))))) | 395 | (setq file (substring file 0 (match-beginning 0))))) |
| 312 | (condition-case alpha | 396 | (condition-case alpha |
| 313 | (unless (member file cus-test-strange-libs) | 397 | (unless (member file cus-test-libs-noloads) |
| 314 | (load-library file)) | 398 | (load-library file) |
| 315 | (error (or | 399 | (push file cus-test-libs-loaded)) |
| 316 | (y-or-n-p | 400 | (error |
| 317 | (format "Load Error for %s: %s\nContinue Loading? " | 401 | (push (cons file alpha) cus-test-libs-errors) |
| 318 | file alpha)) | 402 | (message "Error for %s: %s" file alpha))))) |
| 319 | (error "Load Error for %s: %s" file alpha)))) | 403 | (message "Cus Test Libs loaded %s files." |
| 320 | )) | 404 | (length cus-test-libs-loaded)) |
| 405 | (if cus-test-libs-errors | ||
| 406 | (message "The following load problems appeared:\n%s" | ||
| 407 | cus-test-libs-errors) | ||
| 408 | (message "No load problems encountered by Cus Test Libs")) | ||
| 321 | (run-hooks 'cus-test-after-load-libs-hook)) | 409 | (run-hooks 'cus-test-after-load-libs-hook)) |
| 322 | 410 | ||
| 323 | (defun cus-test-all nil | ||
| 324 | "Run a maximal test by cus-test. | ||
| 325 | This function is suitable for batch mode. E.g., invoke | ||
| 326 | |||
| 327 | src/emacs -batch -l admin/cus-test.el -f cus-test-all | ||
| 328 | |||
| 329 | in the emacs source directory." | ||
| 330 | (interactive) | ||
| 331 | ;; This does not seem to increase the number of tested options. | ||
| 332 | ;; (message "Running %s" 'cus-test-load-libs) | ||
| 333 | ;; (cus-test-load-libs) | ||
| 334 | (message "Running %s" 'cus-test-load-custom-loads) | ||
| 335 | (cus-test-load-custom-loads) | ||
| 336 | ;; If the second call loads libraries, this indicates that there | ||
| 337 | ;; were load errors in the first run. | ||
| 338 | (message "Running %s again" 'cus-test-load-custom-loads) | ||
| 339 | (cus-test-load-custom-loads) | ||
| 340 | (message "Running %s" 'cus-test-apropos) | ||
| 341 | (cus-test-apropos "") | ||
| 342 | (if cus-test-errors | ||
| 343 | (message "The following variables might have problems:\n%s" | ||
| 344 | cus-test-errors) | ||
| 345 | (message "No problems found by Cus Test"))) | ||
| 346 | |||
| 347 | (provide 'cus-test) | 411 | (provide 'cus-test) |
| 348 | 412 | ||
| 349 | ;;; cus-test.el ends here | 413 | ;;; cus-test.el ends here |