428
|
1 ;; test-harness.el --- Run Emacs Lisp test suites.
|
|
2
|
1751
|
3 ;;; Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
|
826
|
4 ;;; Copyright (C) 2002 Ben Wing.
|
428
|
5
|
|
6 ;; Author: Martin Buchholz
|
1761
|
7 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
|
428
|
8 ;; Keywords: testing
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
25 ;; Boston, MA 02111-1307, USA.
|
|
26
|
|
27 ;;; Synched up with: Not in FSF.
|
|
28
|
|
29 ;;; Commentary:
|
|
30
|
|
31 ;;; A test suite harness for testing XEmacs.
|
|
32 ;;; The actual tests are in other files in this directory.
|
|
33 ;;; Basically you just create files of emacs-lisp, and use the
|
1095
|
34 ;;; Assert, Check-Error, Check-Message, and Check-Error-Message functions
|
|
35 ;;; to create tests. See `test-harness-from-buffer' below.
|
|
36 ;;; Don't suppress tests just because they're due to known bugs not yet
|
1413
|
37 ;;; fixed -- use the Known-Bug-Expect-Failure and
|
|
38 ;;; Implementation-Incomplete-Expect-Failure wrapper macros to mark them.
|
1095
|
39 ;;; A lot of the tests we run push limits; suppress Ebola message with the
|
|
40 ;;; Ignore-Ebola wrapper macro.
|
|
41 ;;;
|
428
|
42 ;;; You run the tests using M-x test-emacs-test-file,
|
|
43 ;;; or $(EMACS) -batch -l .../test-harness.el -f batch-test-emacs file ...
|
|
44 ;;; which is run for you by the `make check' target in the top-level Makefile.
|
|
45
|
|
46 (require 'bytecomp)
|
|
47
|
1758
|
48 (defvar test-harness-test-compiled nil
|
|
49 "Non-nil means the test code was compiled before execution.")
|
|
50
|
428
|
51 (defvar test-harness-verbose
|
|
52 (and (not noninteractive) (> (device-baud-rate) search-slow-speed))
|
|
53 "*Non-nil means print messages describing progress of emacs-tester.")
|
|
54
|
1719
|
55 (defvar test-harness-file-results-alist nil
|
|
56 "Each element is a list (FILE SUCCESSES TESTS).
|
|
57 The order is the reverse of the order in which tests are run.
|
|
58
|
|
59 FILE is a string naming the test file.
|
|
60 SUCCESSES is a non-negative integer, the number of successes.
|
|
61 TESTS is a non-negative integer, the number of tests run.")
|
|
62
|
1425
|
63 (defvar test-harness-risk-infloops nil
|
|
64 "*Non-nil to run tests that may loop infinitely in buggy implementations.")
|
|
65
|
428
|
66 (defvar test-harness-current-file nil)
|
|
67
|
|
68 (defvar emacs-lisp-file-regexp (purecopy "\\.el\\'")
|
|
69 "*Regexp which matches Emacs Lisp source files.")
|
|
70
|
1751
|
71 (defconst test-harness-file-summary-template
|
|
72 (format "%%-%ds %%%dd of %%%dd tests successful (%%3d%%%%)."
|
|
73 (length "byte-compiler-tests.el:") ; use the longest file name
|
|
74 5
|
|
75 5)
|
|
76 "Format for summary lines printed after each file is run.")
|
|
77
|
|
78 (defconst test-harness-null-summary-template
|
|
79 (format "%%-%ds No tests run."
|
|
80 (length "byte-compiler-tests.el:")) ; use the longest file name
|
|
81 "Format for \"No tests\" lines printed after a file is run.")
|
|
82
|
428
|
83 ;;;###autoload
|
|
84 (defun test-emacs-test-file (filename)
|
|
85 "Test a file of Lisp code named FILENAME.
|
|
86 The output file's name is made by appending `c' to the end of FILENAME."
|
|
87 (interactive
|
|
88 (let ((file buffer-file-name)
|
|
89 (file-name nil)
|
|
90 (file-dir nil))
|
|
91 (and file
|
|
92 (eq (cdr (assq 'major-mode (buffer-local-variables)))
|
|
93 'emacs-lisp-mode)
|
|
94 (setq file-name (file-name-nondirectory file)
|
|
95 file-dir (file-name-directory file)))
|
|
96 (list (read-file-name "Test file: " file-dir nil nil file-name))))
|
|
97 ;; Expand now so we get the current buffer's defaults
|
|
98 (setq filename (expand-file-name filename))
|
|
99
|
|
100 ;; If we're testing a file that's in a buffer and is modified, offer
|
|
101 ;; to save it first.
|
|
102 (or noninteractive
|
|
103 (let ((b (get-file-buffer (expand-file-name filename))))
|
|
104 (if (and b (buffer-modified-p b)
|
|
105 (y-or-n-p (format "save buffer %s first? " (buffer-name b))))
|
|
106 (save-excursion (set-buffer b) (save-buffer)))))
|
|
107
|
|
108 (if (or noninteractive test-harness-verbose)
|
|
109 (message "Testing %s..." filename))
|
|
110 (let ((test-harness-current-file filename)
|
|
111 input-buffer)
|
|
112 (save-excursion
|
|
113 (setq input-buffer (get-buffer-create " *Test Input*"))
|
|
114 (set-buffer input-buffer)
|
|
115 (erase-buffer)
|
|
116 (insert-file-contents filename)
|
|
117 ;; Run hooks including the uncompression hook.
|
|
118 ;; If they change the file name, then change it for the output also.
|
|
119 (let ((buffer-file-name filename)
|
|
120 (default-major-mode 'emacs-lisp-mode)
|
|
121 (enable-local-eval nil))
|
|
122 (normal-mode)
|
|
123 (setq filename buffer-file-name)))
|
|
124 (test-harness-from-buffer input-buffer filename)
|
|
125 (kill-buffer input-buffer)
|
|
126 ))
|
|
127
|
|
128 (defun test-harness-read-from-buffer (buffer)
|
|
129 "Read forms from BUFFER, and turn it into a lambda test form."
|
|
130 (let ((body nil))
|
|
131 (goto-char (point-min) buffer)
|
|
132 (condition-case error-info
|
|
133 (while t
|
|
134 (setq body (cons (read buffer) body)))
|
|
135 (end-of-file nil)
|
|
136 (error
|
1751
|
137 (princ (format "Unexpected error %S reading forms from buffer\n"
|
|
138 error-info))))
|
428
|
139 `(lambda ()
|
|
140 (defvar passes)
|
|
141 (defvar assertion-failures)
|
|
142 (defvar no-error-failures)
|
|
143 (defvar wrong-error-failures)
|
|
144 (defvar missing-message-failures)
|
|
145 (defvar other-failures)
|
|
146
|
|
147 (defvar unexpected-test-suite-failure)
|
|
148 (defvar trick-optimizer)
|
|
149
|
|
150 ,@(nreverse body))))
|
|
151
|
|
152 (defun test-harness-from-buffer (inbuffer filename)
|
|
153 "Run tests in buffer INBUFFER, visiting FILENAME."
|
|
154 (defvar trick-optimizer)
|
|
155 (let ((passes 0)
|
|
156 (assertion-failures 0)
|
|
157 (no-error-failures 0)
|
|
158 (wrong-error-failures 0)
|
|
159 (missing-message-failures 0)
|
|
160 (other-failures 0)
|
|
161
|
973
|
162 ;; #### perhaps this should be a defvar, and output at the very end
|
|
163 ;; OTOH, this way AC types can use a null EMACSPACKAGEPATH to find
|
|
164 ;; what stuff is needed, and ways to avoid using them
|
|
165 (skipped-test-reasons (make-hash-table :test 'equal))
|
|
166
|
428
|
167 (trick-optimizer nil)
|
|
168 (unexpected-test-suite-failure nil)
|
826
|
169 (debug-on-error t)
|
|
170 (pass-stream nil))
|
428
|
171 (with-output-to-temp-buffer "*Test-Log*"
|
826
|
172 (princ (format "Testing %s...\n\n" filename))
|
1095
|
173
|
1413
|
174 (defconst test-harness-failure-tag "FAIL")
|
|
175 (defconst test-harness-success-tag "PASS")
|
1095
|
176
|
|
177 (defmacro Known-Bug-Expect-Failure (&rest body)
|
1413
|
178 `(let ((test-harness-failure-tag "KNOWN BUG")
|
|
179 (test-harness-success-tag "PASS (FAILURE EXPECTED)"))
|
|
180 ,@body))
|
|
181
|
|
182 (defmacro Implementation-Incomplete-Expect-Failure (&rest body)
|
|
183 `(let ((test-harness-failure-tag "IMPLEMENTATION INCOMPLETE")
|
|
184 (test-harness-success-tag "PASS (FAILURE EXPECTED)"))
|
|
185 ,@body))
|
826
|
186
|
|
187 (defun Print-Failure (fmt &rest args)
|
1413
|
188 (setq fmt (format "%s: %s" test-harness-failure-tag fmt))
|
826
|
189 (if (noninteractive) (apply #'message fmt args))
|
|
190 (princ (concat (apply #'format fmt args) "\n")))
|
|
191
|
|
192 (defun Print-Pass (fmt &rest args)
|
1413
|
193 (setq fmt (format "%s: %s" test-harness-success-tag fmt))
|
826
|
194 (and test-harness-verbose
|
|
195 (princ (concat (apply #'format fmt args) "\n"))))
|
|
196
|
973
|
197 (defun Print-Skip (test reason &optional fmt &rest args)
|
1095
|
198 (setq fmt (concat "SKIP: %S BECAUSE %S" fmt))
|
973
|
199 (princ (concat (apply #'format fmt test reason args) "\n")))
|
|
200
|
1095
|
201 (defmacro Skip-Test-Unless (condition reason description &rest body)
|
|
202 "Unless CONDITION is satisfied, skip test BODY.
|
|
203 REASON is a description of the condition failure, and must be unique (it
|
|
204 is used as a hash key). DESCRIPTION describes the tests that were skipped.
|
|
205 BODY is a sequence of expressions and may contain several tests."
|
|
206 `(if (not ,condition)
|
|
207 (let ((count (gethash ,reason skipped-test-reasons)))
|
|
208 (puthash ,reason (if (null count) 1 (1+ count))
|
|
209 skipped-test-reasons)
|
|
210 (Print-Skip ,description ,reason))
|
|
211 ,@body))
|
428
|
212
|
2056
|
213 (defmacro Assert (assertion &optional failing-case)
|
428
|
214 `(condition-case error-info
|
2056
|
215 (progn
|
|
216 (assert ,assertion)
|
|
217 (Print-Pass "%S" (quote ,assertion))
|
|
218 (incf passes))
|
|
219 (cl-assertion-failed
|
|
220 (Print-Failure (if ,failing-case
|
|
221 "Assertion failed: %S; failing case = %S"
|
|
222 "Assertion failed: %S")
|
|
223 (quote ,assertion) ,failing-case)
|
|
224 (incf assertion-failures))
|
|
225 (t (Print-Failure (if ,failing-case
|
|
226 "%S ==> error: %S; failing case = %S"
|
|
227 "%S ==> error: %S")
|
|
228 (quote ,assertion) error-info ,failing-case)
|
|
229 (incf other-failures)
|
|
230 )))
|
|
231
|
428
|
232
|
|
233 (defmacro Check-Error (expected-error &rest body)
|
|
234 (let ((quoted-body (if (= 1 (length body))
|
|
235 `(quote ,(car body)) `(quote (progn ,@body)))))
|
|
236 `(condition-case error-info
|
|
237 (progn
|
|
238 (setq trick-optimizer (progn ,@body))
|
826
|
239 (Print-Failure "%S executed successfully, but expected error %S"
|
428
|
240 ,quoted-body
|
826
|
241 ',expected-error)
|
428
|
242 (incf no-error-failures))
|
|
243 (,expected-error
|
826
|
244 (Print-Pass "%S ==> error %S, as expected"
|
|
245 ,quoted-body ',expected-error)
|
428
|
246 (incf passes))
|
|
247 (error
|
826
|
248 (Print-Failure "%S ==> expected error %S, got error %S instead"
|
|
249 ,quoted-body ',expected-error error-info)
|
428
|
250 (incf wrong-error-failures)))))
|
|
251
|
826
|
252 (defmacro Check-Error-Message (expected-error expected-error-regexp
|
|
253 &rest body)
|
428
|
254 (let ((quoted-body (if (= 1 (length body))
|
|
255 `(quote ,(car body)) `(quote (progn ,@body)))))
|
|
256 `(condition-case error-info
|
|
257 (progn
|
|
258 (setq trick-optimizer (progn ,@body))
|
826
|
259 (Print-Failure "%S executed successfully, but expected error %S"
|
|
260 ,quoted-body ',expected-error)
|
428
|
261 (incf no-error-failures))
|
|
262 (,expected-error
|
|
263 (let ((error-message (second error-info)))
|
|
264 (if (string-match ,expected-error-regexp error-message)
|
|
265 (progn
|
826
|
266 (Print-Pass "%S ==> error %S %S, as expected"
|
|
267 ,quoted-body error-message ',expected-error)
|
428
|
268 (incf passes))
|
826
|
269 (Print-Failure "%S ==> got error %S as expected, but error message %S did not match regexp %S"
|
|
270 ,quoted-body ',expected-error error-message ,expected-error-regexp)
|
428
|
271 (incf wrong-error-failures))))
|
|
272 (error
|
826
|
273 (Print-Failure "%S ==> expected error %S, got error %S instead"
|
|
274 ,quoted-body ',expected-error error-info)
|
428
|
275 (incf wrong-error-failures)))))
|
|
276
|
|
277
|
|
278 (defmacro Check-Message (expected-message-regexp &rest body)
|
1095
|
279 (Skip-Test-Unless (fboundp 'defadvice)
|
|
280 "can't defadvice"
|
|
281 expected-message-regexp
|
973
|
282 (let ((quoted-body (if (= 1 (length body))
|
|
283 `(quote ,(car body))
|
|
284 `(quote (progn ,@body)))))
|
|
285 `(let ((messages ""))
|
|
286 (defadvice message (around collect activate)
|
|
287 (defvar messages)
|
|
288 (let ((msg-string (apply 'format (ad-get-args 0))))
|
|
289 (setq messages (concat messages msg-string))
|
|
290 msg-string))
|
|
291 (condition-case error-info
|
|
292 (progn
|
|
293 (setq trick-optimizer (progn ,@body))
|
|
294 (if (string-match ,expected-message-regexp messages)
|
|
295 (progn
|
|
296 (Print-Pass "%S ==> value %S, message %S, matching %S, as expected"
|
|
297 ,quoted-body trick-optimizer messages ',expected-message-regexp)
|
|
298 (incf passes))
|
|
299 (Print-Failure "%S ==> value %S, message %S, NOT matching expected %S"
|
|
300 ,quoted-body trick-optimizer messages
|
|
301 ',expected-message-regexp)
|
|
302 (incf missing-message-failures)))
|
|
303 (error
|
|
304 (Print-Failure "%S ==> unexpected error %S"
|
|
305 ,quoted-body error-info)
|
|
306 (incf other-failures)))
|
|
307 (ad-unadvise 'message)))))
|
428
|
308
|
|
309 (defmacro Ignore-Ebola (&rest body)
|
|
310 `(let ((debug-issue-ebola-notices -42)) ,@body))
|
|
311
|
|
312 (defun Int-to-Marker (pos)
|
|
313 (save-excursion
|
|
314 (set-buffer standard-output)
|
|
315 (save-excursion
|
|
316 (goto-char pos)
|
|
317 (point-marker))))
|
|
318
|
|
319 (princ "Testing Interpreted Lisp\n\n")
|
|
320 (condition-case error-info
|
|
321 (funcall (test-harness-read-from-buffer inbuffer))
|
|
322 (error
|
|
323 (setq unexpected-test-suite-failure t)
|
|
324 (princ (format "Unexpected error %S while executing interpreted code\n"
|
|
325 error-info))
|
|
326 (message "Unexpected error %S while executing interpreted code." error-info)
|
|
327 (message "Test suite execution aborted." error-info)
|
|
328 ))
|
|
329 (princ "\nTesting Compiled Lisp\n\n")
|
1758
|
330 (let (code
|
|
331 (test-harness-test-compiled t))
|
428
|
332 (condition-case error-info
|
446
|
333 (setq code
|
|
334 ;; our lisp code is often intentionally dubious,
|
|
335 ;; so throw away _all_ the byte compiler warnings.
|
|
336 (letf (((symbol-function 'byte-compile-warn) 'ignore))
|
|
337 (byte-compile (test-harness-read-from-buffer inbuffer))))
|
428
|
338 (error
|
|
339 (princ (format "Unexpected error %S while byte-compiling code\n"
|
|
340 error-info))))
|
|
341 (condition-case error-info
|
|
342 (if code (funcall code))
|
|
343 (error
|
|
344 (princ (format "Unexpected error %S while executing byte-compiled code\n"
|
|
345 error-info))
|
|
346 (message "Unexpected error %S while executing byte-compiled code." error-info)
|
|
347 (message "Test suite execution aborted." error-info)
|
|
348 )))
|
826
|
349 (princ (format "\nSUMMARY for %s:\n" filename))
|
428
|
350 (princ (format "\t%5d passes\n" passes))
|
|
351 (princ (format "\t%5d assertion failures\n" assertion-failures))
|
|
352 (princ (format "\t%5d errors that should have been generated, but weren't\n" no-error-failures))
|
|
353 (princ (format "\t%5d wrong-error failures\n" wrong-error-failures))
|
|
354 (princ (format "\t%5d missing-message failures\n" missing-message-failures))
|
|
355 (princ (format "\t%5d other failures\n" other-failures))
|
|
356 (let* ((total (+ passes
|
|
357 assertion-failures
|
|
358 no-error-failures
|
|
359 wrong-error-failures
|
|
360 missing-message-failures
|
|
361 other-failures))
|
|
362 (basename (file-name-nondirectory filename))
|
|
363 (summary-msg
|
|
364 (if (> total 0)
|
1751
|
365 (format test-harness-file-summary-template
|
|
366 (concat basename ":")
|
|
367 passes total (/ (* 100 passes) total))
|
|
368 (format test-harness-null-summary-template
|
|
369 (concat basename ":"))))
|
973
|
370 (reasons ""))
|
|
371 (maphash (lambda (key value)
|
|
372 (setq reasons
|
|
373 (concat reasons
|
1095
|
374 (format "\n %d tests skipped because %s."
|
973
|
375 value key))))
|
|
376 skipped-test-reasons)
|
|
377 (when (> (length reasons) 1)
|
|
378 (setq summary-msg (concat summary-msg reasons "
|
|
379 Probably XEmacs cannot find your installed packages. Set EMACSPACKAGEPATH
|
|
380 to the package hierarchy root or configure with --package-path to enable
|
|
381 the skipped tests.")))
|
1719
|
382 (setq test-harness-file-results-alist
|
|
383 (cons (list filename passes total)
|
|
384 test-harness-file-results-alist))
|
428
|
385 (message "%s" summary-msg))
|
|
386 (when unexpected-test-suite-failure
|
|
387 (message "Test suite execution failed unexpectedly."))
|
|
388 (fmakunbound 'Assert)
|
|
389 (fmakunbound 'Check-Error)
|
863
|
390 (fmakunbound 'Check-Message)
|
|
391 (fmakunbound 'Check-Error-Message)
|
428
|
392 (fmakunbound 'Ignore-Ebola)
|
|
393 (fmakunbound 'Int-to-Marker)
|
1719
|
394 (and noninteractive
|
|
395 (message "%s" (buffer-substring-no-properties
|
1751
|
396 nil nil "*Test-Log*")))
|
|
397 )))
|
428
|
398
|
|
399 (defvar test-harness-results-point-max nil)
|
|
400 (defmacro displaying-emacs-test-results (&rest body)
|
|
401 `(let ((test-harness-results-point-max test-harness-results-point-max))
|
|
402 ;; Log the file name.
|
|
403 (test-harness-log-file)
|
|
404 ;; Record how much is logged now.
|
|
405 ;; We will display the log buffer if anything more is logged
|
|
406 ;; before the end of BODY.
|
|
407 (or test-harness-results-point-max
|
|
408 (save-excursion
|
|
409 (set-buffer (get-buffer-create "*Test-Log*"))
|
|
410 (setq test-harness-results-point-max (point-max))))
|
|
411 (unwind-protect
|
|
412 (condition-case error-info
|
|
413 (progn ,@body)
|
|
414 (error
|
|
415 (test-harness-report-error error-info)))
|
|
416 (save-excursion
|
|
417 ;; If there were compilation warnings, display them.
|
|
418 (set-buffer "*Test-Log*")
|
|
419 (if (= test-harness-results-point-max (point-max))
|
|
420 nil
|
|
421 (if temp-buffer-show-function
|
|
422 (let ((show-buffer (get-buffer-create "*Test-Log-Show*")))
|
|
423 (save-excursion
|
|
424 (set-buffer show-buffer)
|
|
425 (setq buffer-read-only nil)
|
|
426 (erase-buffer))
|
|
427 (copy-to-buffer show-buffer
|
|
428 (save-excursion
|
|
429 (goto-char test-harness-results-point-max)
|
|
430 (forward-line -1)
|
|
431 (point))
|
|
432 (point-max))
|
|
433 (funcall temp-buffer-show-function show-buffer))
|
|
434 (select-window
|
|
435 (prog1 (selected-window)
|
|
436 (select-window (display-buffer (current-buffer)))
|
|
437 (goto-char test-harness-results-point-max)
|
|
438 (recenter 1)))))))))
|
|
439
|
|
440 (defun batch-test-emacs-1 (file)
|
|
441 (condition-case error-info
|
|
442 (progn (test-emacs-test-file file) t)
|
|
443 (error
|
|
444 (princ ">>Error occurred processing ")
|
|
445 (princ file)
|
|
446 (princ ": ")
|
|
447 (display-error error-info nil)
|
|
448 (terpri)
|
|
449 nil)))
|
|
450
|
|
451 (defun batch-test-emacs ()
|
|
452 "Run `test-harness' on the files remaining on the command line.
|
|
453 Use this from the command line, with `-batch';
|
|
454 it won't work in an interactive Emacs.
|
|
455 Each file is processed even if an error occurred previously.
|
|
456 For example, invoke \"xemacs -batch -f batch-test-emacs tests/*.el\""
|
|
457 ;; command-line-args-left is what is left of the command line (from
|
|
458 ;; startup.el)
|
|
459 (defvar command-line-args-left) ;Avoid 'free variable' warning
|
|
460 (defvar debug-issue-ebola-notices)
|
|
461 (if (not noninteractive)
|
|
462 (error "`batch-test-emacs' is to be used only with -batch"))
|
|
463 (let ((error nil))
|
|
464 (dolist (file command-line-args-left)
|
|
465 (if (file-directory-p file)
|
|
466 (dolist (file-in-dir (directory-files file t))
|
|
467 (when (and (string-match emacs-lisp-file-regexp file-in-dir)
|
|
468 (not (or (auto-save-file-name-p file-in-dir)
|
|
469 (backup-file-name-p file-in-dir)
|
|
470 (equal (file-name-nondirectory file-in-dir)
|
|
471 "test-harness.el"))))
|
|
472 (or (batch-test-emacs-1 file-in-dir)
|
|
473 (setq error t))))
|
|
474 (or (batch-test-emacs-1 file)
|
|
475 (setq error t))))
|
1719
|
476 (let ((namelen 0)
|
|
477 (succlen 0)
|
|
478 (testlen 0)
|
|
479 (results test-harness-file-results-alist))
|
|
480 ;; compute maximum lengths of variable components of report
|
|
481 ;; probably should just use (length "byte-compiler-tests.el")
|
|
482 ;; and 5-place sizes -- this will also work for the file-by-file
|
|
483 ;; printing when Adrian's kludge gets reverted
|
|
484 (flet ((print-width (i)
|
|
485 (let ((x 10) (y 1))
|
|
486 (while (>= i x)
|
|
487 (setq x (* 10 x) y (1+ y)))
|
|
488 y)))
|
|
489 (while results
|
|
490 (let* ((head (car results))
|
|
491 (nn (length (file-name-nondirectory (first head))))
|
|
492 (ss (print-width (second head)))
|
|
493 (tt (print-width (third head))))
|
|
494 (when (> nn namelen) (setq namelen nn))
|
|
495 (when (> ss succlen) (setq succlen ss))
|
|
496 (when (> tt testlen) (setq testlen tt)))
|
|
497 (setq results (cdr results))))
|
|
498 ;; create format and print
|
1751
|
499 (let ((results (reverse test-harness-file-results-alist)))
|
1719
|
500 (while results
|
|
501 (let* ((head (car results))
|
1751
|
502 (basename (file-name-nondirectory (first head)))
|
1719
|
503 (nsucc (second head))
|
|
504 (ntest (third head)))
|
1722
|
505 (if (> ntest 0)
|
1751
|
506 (message test-harness-file-summary-template
|
|
507 (concat basename ":")
|
1722
|
508 nsucc
|
|
509 ntest
|
|
510 (/ (* 100 nsucc) ntest))
|
1751
|
511 (message test-harness-null-summary-template
|
|
512 (concat basename ":")))
|
1719
|
513 (setq results (cdr results))))))
|
|
514 (message "\nDone")
|
428
|
515 (kill-emacs (if error 1 0))))
|
|
516
|
|
517 (provide 'test-harness)
|
|
518
|
|
519 ;;; test-harness.el ends here
|