Extended and reorganized.
There are now 3 tests which can be run in batch mode. See the Commentary section.
This commit is contained in:
parent
e3264d0caa
commit
592cd48bf6
2 changed files with 196 additions and 132 deletions
|
@ -1,7 +1,7 @@
|
|||
2002-10-09 Markus Rost <rost@math.ohio-state.edu>
|
||||
2002-10-10 Markus Rost <rost@math.ohio-state.edu>
|
||||
|
||||
* cus-test.el: Clean up workarounds. Shorten variable names.
|
||||
Use cus-test-vars-with-changed-state in a different way.
|
||||
* cus-test.el: Extended and reorganized. There are now 3 tests
|
||||
which can be run in batch mode. See the Commentary section.
|
||||
|
||||
2002-10-08 Markus Rost <rost@math.ohio-state.edu>
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
;; Some user options in GNU Emacs have been defined with incorrect
|
||||
;; customization types. As a result the customization of these
|
||||
;; options is disabled. This file provides functions to detect such
|
||||
;; options.
|
||||
;; options. It contains also simple tests for loading libraries and
|
||||
;; custom dependencies.
|
||||
;;
|
||||
;; Usage: Load this file. Then
|
||||
;;
|
||||
|
@ -46,33 +47,10 @@
|
|||
;; Therefore `cus-test-apropos' is more efficient after loading many
|
||||
;; libraries.
|
||||
;;
|
||||
;; M-x cus-test-library LIB RET
|
||||
;;
|
||||
;; loads library LIB and checks the options matching LIB.
|
||||
;;
|
||||
;; M-x cus-test-load-custom-loads RET
|
||||
;;
|
||||
;; loads all (!) custom dependencies.
|
||||
;;
|
||||
;; M-x cus-test-load-libs RET
|
||||
;;
|
||||
;; loads all (!) libraries with autoloads. This function is useful to
|
||||
;; detect load problems of libraries.
|
||||
;;
|
||||
;; For a maximal test of custom options invoke
|
||||
;;
|
||||
;; M-x cus-test-all
|
||||
;;
|
||||
;; This function is suitable for batch mode. E.g., invoke
|
||||
;;
|
||||
;; src/emacs -batch -l admin/cus-test.el -f cus-test-all
|
||||
;;
|
||||
;; in the emacs source directory.
|
||||
;;
|
||||
;; To make cus-test work one has usually to work-around some existing
|
||||
;; bugs/problems. Therefore this file contains a "Workaround"
|
||||
;; section, to be edited once in a while.
|
||||
;;
|
||||
;; Options with a custom-get property, usually defined by a :get
|
||||
;; declaration, are stored in the variable
|
||||
;;
|
||||
|
@ -86,48 +64,52 @@
|
|||
;; These lists are prepared just in case one wants to investigate
|
||||
;; those options further.
|
||||
;;
|
||||
;; Current result (Oct 6, 2002) of cus-test-all:
|
||||
;; For a maximal test of custom options invoke
|
||||
;;
|
||||
;; Cus Test tested 4514 variables.
|
||||
;; M-x cus-test-opts
|
||||
;;
|
||||
;; Other test routines are `cus-test-deps' and `cus-test-libs'.
|
||||
;; These functions are suitable for batch mode. Invoke them with
|
||||
;;
|
||||
;; src/emacs -batch -l admin/cus-test.el -f cus-test-opts
|
||||
;;
|
||||
;; src/emacs -batch -l admin/cus-test.el -f cus-test-deps
|
||||
;;
|
||||
;; src/emacs -batch -l admin/cus-test.el -f cus-test-libs
|
||||
;;
|
||||
;; in the emacs source directory.
|
||||
;;
|
||||
;; To make cus-test work one has usually to work-around some existing
|
||||
;; bugs/problems. Therefore this file contains "Fixme" and
|
||||
;; "Workarounds" sections, to be edited once in a while.
|
||||
;;
|
||||
;; Results from Oct 10, 2002:
|
||||
;;
|
||||
;; Cus Test tested 4514 options.
|
||||
;; The following variables might have problems:
|
||||
;; (ps-mule-font-info-database-default)
|
||||
|
||||
;; Cus Test Deps loaded 332 files.
|
||||
;; The following load problems appeared:
|
||||
;; ((killing x-win (file-error Cannot open load file x-win)))
|
||||
|
||||
;; Cus Test Libs loaded 424 files.
|
||||
;; No load problems encountered by Cus Test Libs
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; User variables:
|
||||
|
||||
(defvar cus-test-strange-vars nil
|
||||
"*List of variables to disregard by `cus-test-apropos'.")
|
||||
|
||||
(defvar cus-test-strange-libs nil
|
||||
"*List of libraries to avoid by `cus-test-load-libs'.")
|
||||
;;; Variables for workarounds:
|
||||
|
||||
(defvar cus-test-after-load-libs-hook nil
|
||||
"*Hook to repair the worst side effects of loading buggy libraries.
|
||||
It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'")
|
||||
"Hook to repair the worst side effects of loading buggy libraries.")
|
||||
|
||||
;;; Workarounds:
|
||||
(defvar cus-test-libs-noloads nil
|
||||
"List of libraries not to load by `cus-test-libs'.")
|
||||
|
||||
;; The file eudc-export.el loads libraries "bbdb" and "bbdb-com" which
|
||||
;; are not part of GNU Emacs.
|
||||
(provide 'bbdb)
|
||||
(provide 'bbdb-com)
|
||||
;; (locate-library "bbdb")
|
||||
|
||||
;; reftex must be loaded before reftex-vars.
|
||||
(load "reftex")
|
||||
|
||||
;; eshell must be loaded before em-script. eshell loads esh-util,
|
||||
;; which must be loaded before em-cmpl, em-dirs and similar libraries.
|
||||
(load "eshell")
|
||||
|
||||
;; Loading dunnet in batch mode leads to a dead end.
|
||||
(when noninteractive
|
||||
(let (noninteractive) (load "dunnet"))
|
||||
(add-to-list 'cus-test-strange-libs "dunnet"))
|
||||
;;; Fixme:
|
||||
|
||||
;; Loading filesets.el currently disables mini-buffer echoes.
|
||||
;; (add-to-list 'cus-test-strange-libs "filesets")
|
||||
;; (add-to-list 'cus-test-libs-noloads "filesets")
|
||||
(add-hook
|
||||
'cus-test-after-load-libs-hook
|
||||
(lambda nil
|
||||
|
@ -138,16 +120,37 @@ It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'")
|
|||
))
|
||||
;; (setq cus-test-after-load-libs-hook nil)
|
||||
|
||||
;; eshell must be loaded before em-script. eshell loads esh-util,
|
||||
;; which must be loaded before em-cmpl, em-dirs and similar libraries.
|
||||
(load "eshell")
|
||||
|
||||
;; reftex must be loaded before reftex-vars.
|
||||
(load "reftex")
|
||||
|
||||
;;; Workarounds:
|
||||
|
||||
;; The file eudc-export.el loads libraries "bbdb" and "bbdb-com" which
|
||||
;; are not part of GNU Emacs: (locate-library "bbdb") => nil
|
||||
|
||||
;; This avoids the resulting errors from loading eudc-export.el.
|
||||
(provide 'bbdb)
|
||||
(provide 'bbdb-com)
|
||||
|
||||
;; Loading dunnet in batch mode leads to a Dead end.
|
||||
(let (noninteractive)
|
||||
(load "dunnet"))
|
||||
(add-to-list 'cus-test-libs-noloads "dunnet")
|
||||
|
||||
;;; Silencing:
|
||||
|
||||
;; Don't create a file filesets-menu-cache-file.
|
||||
;; Don't create a file `filesets-menu-cache-file'.
|
||||
(setq filesets-menu-cache-file "")
|
||||
|
||||
;; Don't create a file save-place-file.
|
||||
;; Don't create a file `save-place-file'.
|
||||
(eval-after-load "saveplace"
|
||||
'(remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
|
||||
|
||||
;; Don't create a file abbrev-file-name.
|
||||
;; Don't create a file `abbrev-file-name'.
|
||||
(setq save-abbrevs nil)
|
||||
|
||||
;; Avoid compile logs from adviced functions.
|
||||
|
@ -160,12 +163,27 @@ It is run after `cus-test-load-custom-loads' and `cus-test-load-libs'")
|
|||
|
||||
;;; Main Code:
|
||||
|
||||
(require 'cus-edit)
|
||||
(require 'cus-load)
|
||||
|
||||
(defvar cus-test-tested-variables nil
|
||||
"Options tested by last call of `cus-test-apropos'.")
|
||||
|
||||
(defvar cus-test-errors nil
|
||||
"List of problematic variables found by `cus-test-apropos'.")
|
||||
|
||||
(defvar cus-test-deps-errors nil
|
||||
"List of require/load problems found by `cus-test-deps'.")
|
||||
|
||||
(defvar cus-test-deps-tested nil
|
||||
"Dependencies loaded by `cus-test-deps'.")
|
||||
|
||||
(defvar cus-test-libs-errors nil
|
||||
"List of load problems found by `cus-test-libs'.")
|
||||
|
||||
(defvar cus-test-libs-loaded nil
|
||||
"Files loaded by `cus-test-libs'.")
|
||||
|
||||
;; I haven't understood this :get stuff. However, there are only very
|
||||
;; few variables with a custom-get property. Such symbols are stored
|
||||
;; 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'")
|
|||
(defvar cus-test-vars-with-changed-state nil
|
||||
"Set by `cus-test-apropos' to a list of options with state 'changed.")
|
||||
|
||||
(require 'cus-edit)
|
||||
(require 'cus-load)
|
||||
|
||||
(defun cus-test-apropos (regexp)
|
||||
"Check the options matching REGEXP.
|
||||
The detected problematic options are stored in `cus-test-errors'."
|
||||
|
@ -193,19 +208,16 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(condition-case alpha
|
||||
(let* ((type (custom-variable-type symbol))
|
||||
(conv (widget-convert type))
|
||||
;; I haven't understood this :get stuff.
|
||||
(get (or (get symbol 'custom-get) 'default-value))
|
||||
values
|
||||
mismatch)
|
||||
(when (default-boundp symbol)
|
||||
(add-to-list 'values
|
||||
(funcall get symbol))
|
||||
(add-to-list 'values
|
||||
(eval (car (get symbol 'standard-value)))))
|
||||
(push (funcall get symbol) values)
|
||||
(push (eval (car (get symbol 'standard-value))) values))
|
||||
(if (boundp symbol)
|
||||
(add-to-list 'values (symbol-value symbol)))
|
||||
(push (symbol-value symbol) values))
|
||||
;; That does not work.
|
||||
;; (add-to-list 'values (widget-get conv :value))
|
||||
;; (push (widget-get conv :value) values)
|
||||
|
||||
;; Check the values
|
||||
(mapcar (lambda (value)
|
||||
|
@ -213,6 +225,10 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(setq mismatch 'mismatch)))
|
||||
values)
|
||||
|
||||
;; Store symbols with a custom-get property.
|
||||
(when (get symbol 'custom-get)
|
||||
(push symbol cus-test-vars-with-custom-get))
|
||||
|
||||
;; Changed outside the customize buffer?
|
||||
;; This routine is not very much tested.
|
||||
(let ((c-value
|
||||
|
@ -222,31 +238,18 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(and (consp c-value)
|
||||
(boundp symbol)
|
||||
(not (equal (eval (car c-value)) (symbol-value symbol)))
|
||||
(add-to-list 'cus-test-vars-with-changed-state symbol)))
|
||||
|
||||
;; Store symbols with a custom-get property.
|
||||
(when (get symbol 'custom-get)
|
||||
(add-to-list 'cus-test-vars-with-custom-get symbol)
|
||||
;; No need anymore to ignore them.
|
||||
;; (setq mismatch nil)
|
||||
)
|
||||
(push symbol cus-test-vars-with-changed-state)))
|
||||
|
||||
(if mismatch
|
||||
(add-to-list 'cus-test-errors symbol)))
|
||||
(push symbol cus-test-errors)))
|
||||
|
||||
(error
|
||||
(add-to-list 'cus-test-errors symbol)
|
||||
(if (y-or-n-p
|
||||
(format "Error for %s: %s\nContinue? "
|
||||
symbol alpha))
|
||||
(message "Error for %s: %s" symbol alpha)
|
||||
(error "Error for %s: %s" symbol alpha)))))
|
||||
(push symbol cus-test-errors)
|
||||
(message "Error for %s: %s" symbol alpha))))
|
||||
(cus-test-get-options regexp))
|
||||
(message "Cus Test tested %s variables."
|
||||
(message "Cus Test tested %s options."
|
||||
(length cus-test-tested-variables))
|
||||
;; (describe-variable 'cus-test-errors)
|
||||
(cus-test-errors-display)
|
||||
)
|
||||
(cus-test-errors-display))
|
||||
|
||||
(defun cus-test-get-options (regexp)
|
||||
"Return a list of custom options matching REGEXP."
|
||||
|
@ -260,7 +263,7 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
;; (get symbol 'saved-value)
|
||||
(get symbol 'custom-type))
|
||||
(string-match regexp (symbol-name symbol))
|
||||
(not (member symbol cus-test-strange-vars))
|
||||
;; (not (member symbol cus-test-strange-vars))
|
||||
(push symbol found))))
|
||||
found))
|
||||
|
||||
|
@ -278,24 +281,105 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(setq L (cdr L))))
|
||||
(insert "No errors found by cus-test."))))
|
||||
|
||||
(defun cus-test-library (lib)
|
||||
"Load library LIB and call `cus-test-apropos' on LIB."
|
||||
(interactive "sTest variables in library: ")
|
||||
(load-library lib)
|
||||
(cus-test-apropos lib))
|
||||
|
||||
(defun cus-test-load-custom-loads nil
|
||||
"Call `custom-load-symbol' on all atoms."
|
||||
(interactive)
|
||||
(mapatoms 'custom-load-symbol)
|
||||
(run-hooks 'cus-test-after-load-libs-hook))
|
||||
|
||||
(defun cus-test-load-libs ()
|
||||
"Load the libraries with autoloads in loaddefs.el.
|
||||
Don't load libraries in `cus-test-strange-libs'.
|
||||
;;; The routines for batch mode:
|
||||
|
||||
This function is useful to detect load problems of libraries."
|
||||
(defun cus-test-opts nil
|
||||
"Test custom options.
|
||||
This function is suitable for batch mode. E.g., invoke
|
||||
|
||||
src/emacs -batch -l admin/cus-test.el -f cus-test-opts
|
||||
|
||||
in the emacs source directory."
|
||||
(interactive)
|
||||
(message "Running %s" 'cus-test-load-custom-loads)
|
||||
(cus-test-load-custom-loads)
|
||||
(message "Running %s" 'cus-test-apropos)
|
||||
(cus-test-apropos "")
|
||||
(if cus-test-errors
|
||||
(message "The following options might have problems:\n%s"
|
||||
cus-test-errors)
|
||||
(message "No problems found by Cus Test Opts")))
|
||||
|
||||
(defun cus-test-deps nil
|
||||
"Run a verbose version of `custom-load-symbol' on all atoms.
|
||||
This function is suitable for batch mode. E.g., invoke
|
||||
|
||||
src/emacs -batch -l admin/cus-test.el -f cus-test-deps
|
||||
|
||||
in the emacs source directory."
|
||||
(interactive)
|
||||
(setq cus-test-deps-errors nil)
|
||||
(setq cus-test-deps-tested nil)
|
||||
(mapatoms
|
||||
;; This code is mainly from `custom-load-symbol'.
|
||||
(lambda (symbol)
|
||||
(unless custom-load-recursion
|
||||
(let ((custom-load-recursion t))
|
||||
(dolist (load (get symbol 'custom-loads))
|
||||
(cond
|
||||
((symbolp load)
|
||||
;; (condition-case nil (require load) (error nil))
|
||||
(condition-case alpha
|
||||
(require load)
|
||||
(error
|
||||
(push (list symbol load alpha) cus-test-deps-errors)
|
||||
(message "Require problem: %s %s: %s" symbol load alpha)))
|
||||
(push (list symbol load) cus-test-deps-tested))
|
||||
;; This is subsumed by the test below, but it's much
|
||||
;; faster.
|
||||
((assoc load load-history))
|
||||
;; This was just
|
||||
;; (assoc (locate-library load) load-history)
|
||||
;; but has been optimized not to load locate-library
|
||||
;; if not necessary.
|
||||
((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
|
||||
"\\(\\'\\|\\.\\)"))
|
||||
(found nil))
|
||||
(dolist (loaded load-history)
|
||||
(and (stringp (car loaded))
|
||||
(string-match regexp (car loaded))
|
||||
(setq found t)))
|
||||
found))
|
||||
;; Without this, we would load cus-edit recursively.
|
||||
;; We are still loading it when we call this,
|
||||
;; and it is not in load-history yet.
|
||||
((equal load "cus-edit"))
|
||||
(t
|
||||
;; (condition-case nil (load load) (error nil))
|
||||
(condition-case alpha
|
||||
(load load)
|
||||
(error
|
||||
(push (list symbol load alpha) cus-test-deps-errors)
|
||||
(message "Load Problem: %s %s: %s" symbol load alpha)))
|
||||
(push (list symbol load) cus-test-deps-tested))
|
||||
))))))
|
||||
(message "Cus Test Deps loaded %s files."
|
||||
(length cus-test-deps-tested))
|
||||
(if cus-test-deps-errors
|
||||
(message "The following load problems appeared:\n%s"
|
||||
cus-test-deps-errors)
|
||||
(message "No load problems encountered by Cus Test Deps"))
|
||||
(run-hooks 'cus-test-after-load-libs-hook))
|
||||
|
||||
(defun cus-test-libs ()
|
||||
"Load the libraries with autoloads in loaddefs.el.
|
||||
Don't load libraries in `cus-test-libs-noloads'.
|
||||
|
||||
This function is useful to detect load problems of libraries.
|
||||
It is suitable for batch mode. E.g., invoke
|
||||
|
||||
src/emacs -batch -l admin/cus-test.el -f cus-test-libs
|
||||
|
||||
in the emacs source directory."
|
||||
(interactive)
|
||||
(setq cus-test-libs-errors nil)
|
||||
(setq cus-test-libs-loaded nil)
|
||||
(set-buffer (find-file-noselect (locate-library "loaddefs")))
|
||||
(goto-char (point-min))
|
||||
(let (file)
|
||||
|
@ -310,40 +394,20 @@ This function is useful to detect load problems of libraries."
|
|||
(when (string-match "\\.el\\'" file)
|
||||
(setq file (substring file 0 (match-beginning 0)))))
|
||||
(condition-case alpha
|
||||
(unless (member file cus-test-strange-libs)
|
||||
(load-library file))
|
||||
(error (or
|
||||
(y-or-n-p
|
||||
(format "Load Error for %s: %s\nContinue Loading? "
|
||||
file alpha))
|
||||
(error "Load Error for %s: %s" file alpha))))
|
||||
))
|
||||
(unless (member file cus-test-libs-noloads)
|
||||
(load-library file)
|
||||
(push file cus-test-libs-loaded))
|
||||
(error
|
||||
(push (cons file alpha) cus-test-libs-errors)
|
||||
(message "Error for %s: %s" file alpha)))))
|
||||
(message "Cus Test Libs loaded %s files."
|
||||
(length cus-test-libs-loaded))
|
||||
(if cus-test-libs-errors
|
||||
(message "The following load problems appeared:\n%s"
|
||||
cus-test-libs-errors)
|
||||
(message "No load problems encountered by Cus Test Libs"))
|
||||
(run-hooks 'cus-test-after-load-libs-hook))
|
||||
|
||||
(defun cus-test-all nil
|
||||
"Run a maximal test by cus-test.
|
||||
This function is suitable for batch mode. E.g., invoke
|
||||
|
||||
src/emacs -batch -l admin/cus-test.el -f cus-test-all
|
||||
|
||||
in the emacs source directory."
|
||||
(interactive)
|
||||
;; This does not seem to increase the number of tested options.
|
||||
;; (message "Running %s" 'cus-test-load-libs)
|
||||
;; (cus-test-load-libs)
|
||||
(message "Running %s" 'cus-test-load-custom-loads)
|
||||
(cus-test-load-custom-loads)
|
||||
;; If the second call loads libraries, this indicates that there
|
||||
;; were load errors in the first run.
|
||||
(message "Running %s again" 'cus-test-load-custom-loads)
|
||||
(cus-test-load-custom-loads)
|
||||
(message "Running %s" 'cus-test-apropos)
|
||||
(cus-test-apropos "")
|
||||
(if cus-test-errors
|
||||
(message "The following variables might have problems:\n%s"
|
||||
cus-test-errors)
|
||||
(message "No problems found by Cus Test")))
|
||||
|
||||
(provide 'cus-test)
|
||||
|
||||
;;; cus-test.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue