annotate tests/test-emacs.el @ 342:b036ce23deaa

Added tag r21-1-0 for changeset 2538ab34df21
author cvs
date Mon, 13 Aug 2007 10:52:06 +0200
parents c5d627a313b1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
1 ;; test-emacs.el --- Run Emacs Lisp test suites.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
2
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1998 Free Software Foundation, Inc.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
4
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
5 ;; Author: Martin Buchholz
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
6 ;; Keywords: testing
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
7
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
9
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
13 ;; any later version.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
14
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
18 ;; General Public License for more details.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
19
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
24
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
26
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
27 (defvar test-emacs-verbose
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
28 (and (not noninteractive) (> (device-baud-rate) search-slow-speed))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
29 "*Non-nil means print messages describing progress of emacs-tester.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
30
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
31 (defvar test-emacs-current-file nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
32
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
33 (defvar emacs-lisp-file-regexp (purecopy "\\.el$")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
34 "*Regexp which matches Emacs Lisp source files.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
35
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
36 (defun test-emacs-test-file (filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
37 "Test a file of Lisp code named FILENAME.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
38 The output file's name is made by appending `c' to the end of FILENAME."
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
39 ;; (interactive "fTest file: ")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
40 (interactive
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
41 (let ((file buffer-file-name)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
42 (file-name nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
43 (file-dir nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
44 (and file
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
45 (eq (cdr (assq 'major-mode (buffer-local-variables)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
46 'emacs-lisp-mode)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
47 (setq file-name (file-name-nondirectory file)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
48 file-dir (file-name-directory file)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
49 (list (read-file-name "Test file: " file-dir nil nil file-name))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
50 ;; Expand now so we get the current buffer's defaults
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
51 (setq filename (expand-file-name filename))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
52
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
53 ;; If we're testing a file that's in a buffer and is modified, offer
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
54 ;; to save it first.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
55 (or noninteractive
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
56 (let ((b (get-file-buffer (expand-file-name filename))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
57 (if (and b (buffer-modified-p b)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
58 (y-or-n-p (format "save buffer %s first? " (buffer-name b))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
59 (save-excursion (set-buffer b) (save-buffer)))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
60
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
61 (if (or noninteractive test-emacs-verbose)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
62 (message "Testing %s..." filename))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
63 (let ((test-emacs-current-file filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
64 input-buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
65 (save-excursion
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
66 (setq input-buffer (get-buffer-create " *Test Input*"))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
67 (set-buffer input-buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
68 (erase-buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
69 (insert-file-contents filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
70 ;; Run hooks including the uncompression hook.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
71 ;; If they change the file name, then change it for the output also.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
72 (let ((buffer-file-name filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
73 (default-major-mode 'emacs-lisp-mode)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
74 (enable-local-eval nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
75 (normal-mode)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
76 (setq filename buffer-file-name)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
77 (test-emacs-from-buffer input-buffer filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
78 (kill-buffer input-buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
79 ))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
80
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
81 (defun test-emacs-read-from-buffer (buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
82 "Read forms from BUFFER, and turn it into a lambda test form."
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
83 (let ((body nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
84 (goto-char (point-min) buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
85 (condition-case nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
86 (while t
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
87 (setq body (cons (read inbuffer) body)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
88 (error nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
89 `(lambda ()
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
90 (defvar passes)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
91 (defvar assertion-failures)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
92 (defvar other-failures)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
93 ,@(nreverse body))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
94
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
95 (defun test-emacs-from-buffer (inbuffer filename)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
96 "Run tests in buffer INBUFFER, visiting FILENAME."
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
97 (let ((passes 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
98 (assertion-failures 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
99 (other-failures 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
100 (with-output-to-temp-buffer "*Test-Log*"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
101 (defmacro Assert (assertion)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
102 `(condition-case error
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
103 (progn
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
104 (assert ,assertion)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
105 (princ (format "PASS: %S" (quote ,assertion)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
106 (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
107 (incf passes))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
108 (cl-assertion-failed
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
109 (princ (format "Assertion failed: %S" (quote ,assertion)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
110 (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
111 (incf assertion-failures))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
112 (t (princ "Error during test execution:\n\t")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
113 (display-error error nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
114 (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
115 (incf other-failures)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
116 )))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
117
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
118 (princ "Testing Interpreted Lisp\n\n")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
119 (funcall (test-emacs-read-from-buffer inbuffer))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
120 (princ "\nTesting Compiled Lisp\n\n")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
121 (funcall (byte-compile (test-emacs-read-from-buffer inbuffer)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
122 (princ (format
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
123 "\nSUMMARY: %d passes, %d assertion failures, %d other failures\n"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
124 passes
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
125 assertion-failures
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
126 other-failures))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
127 (let* ((total (+ passes assertion-failures other-failures))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
128 (basename (file-name-nondirectory filename))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
129 (summary-msg
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
130 (if (> total 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
131 (format "%s: %d of %d (%d%%) tests successful."
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
132 basename passes total (/ (* 100 passes) total))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
133 (format "%s: No tests run" basename))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
134 (message "%s" summary-msg))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
135 (fmakunbound 'Assert))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
136
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
137 (defvar test-emacs-results-point-max nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
138 (defmacro displaying-emacs-test-results (&rest body)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
139 `(let ((test-emacs-results-point-max test-emacs-results-point-max))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
140 ;; Log the file name.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
141 (test-emacs-log-file)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
142 ;; Record how much is logged now.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
143 ;; We will display the log buffer if anything more is logged
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
144 ;; before the end of BODY.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
145 (or test-emacs-results-point-max
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
146 (save-excursion
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
147 (set-buffer (get-buffer-create "*Test-Log*"))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
148 (setq test-emacs-results-point-max (point-max))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
149 (unwind-protect
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
150 (condition-case error-info
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
151 (progn ,@body)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
152 (error
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
153 (test-emacs-report-error error-info)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
154 (save-excursion
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
155 ;; If there were compilation warnings, display them.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
156 (set-buffer "*Test-Log*")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
157 (if (= test-emacs-results-point-max (point-max))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
158 nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
159 (if temp-buffer-show-function
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
160 (let ((show-buffer (get-buffer-create "*Test-Log-Show*")))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
161 (save-excursion
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
162 (set-buffer show-buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
163 (setq buffer-read-only nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
164 (erase-buffer))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
165 (copy-to-buffer show-buffer
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
166 (save-excursion
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
167 (goto-char test-emacs-results-point-max)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
168 (forward-line -1)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
169 (point))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
170 (point-max))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
171 (funcall temp-buffer-show-function show-buffer))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
172 (select-window
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
173 (prog1 (selected-window)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
174 (select-window (display-buffer (current-buffer)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
175 (goto-char test-emacs-results-point-max)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
176 (recenter 1)))))))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
177
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
178 (defun batch-test-emacs-1 (file)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
179 (condition-case err
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
180 (progn (test-emacs-test-file file) t)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
181 (error
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
182 (princ ">>Error occurred processing ")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
183 (princ file)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
184 (princ ": ")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
185 (display-error err nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
186 (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
187 nil)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
188
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
189 (defun batch-test-emacs ()
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
190 "Run `test-emacs' on the files remaining on the command line.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
191 Use this from the command line, with `-batch';
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
192 it won't work in an interactive Emacs.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
193 Each file is processed even if an error occurred previously.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
194 For example, invoke \"xemacs -batch -f batch-test-emacs tests/*.el\""
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
195 ;; command-line-args-left is what is left of the command line (from
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
196 ;; startup.el)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
197 (defvar command-line-args-left) ;Avoid 'free variable' warning
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
198 (if (not noninteractive)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
199 (error "`batch-test-emacs' is to be used only with -batch"))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
200 (let ((error nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
201 (debug-issue-ebola-notices 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
202 (loop for file in command-line-args-left
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
203 do
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
204 (if (file-directory-p (expand-file-name file))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
205 (let ((files (directory-files file))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
206 source)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
207 (while files
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
208 (if (and (string-match emacs-lisp-file-regexp (car files))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
209 (not (auto-save-file-name-p (car files)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
210 (setq source (expand-file-name
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
211 (car files)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
212 file))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
213 (if (null (batch-test-emacs-1 source))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
214 (setq error t)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
215 (setq files (cdr files)))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
216 (if (null (batch-test-emacs-1 file))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
217 (setq error t))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
218 (message "Done")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
219 (kill-emacs (if error 1 0))))