annotate tests/automated/test-harness.el @ 1095:0d33547d9ed3

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