Mercurial > hg > xemacs-beta
annotate lisp/test-harness.el @ 5098:e402e3506a53
Use #'subseq, not #'substring, in native-windows-specific code, make-docfile.el
2010-03-04 Aidan Kehoe <kehoea@parhasard.net>
* make-docfile.el (process-args):
Use #'subseq here, not #'substring, fixing the native Windows
build. Thank you for the error report, Vin!
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 04 Mar 2010 16:47:16 +0000 |
parents | 14f0dd1fabdb |
children | b24cf478a45e |
rev | line source |
---|---|
428 | 1 ;; test-harness.el --- Run Emacs Lisp test suites. |
2 | |
1751 | 3 ;;; Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc. |
4856 | 4 ;;; Copyright (C) 2002, 2010 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. | |
3472 | 41 ;;; Some noisy code will call `message'. Output from `message' can be |
42 ;;; suppressed with the Silence-Message macro. Functions that are known to | |
43 ;;; issue messages include `write-region', `find-tag', `tag-loop-continue', | |
44 ;;; `insert', and `mark-whole-buffer'. N.B. The Silence-Message macro | |
45 ;;; currently does not suppress the newlines printed by `message'. | |
46 ;;; Definitely do not use Silence-Message with Check-Message. | |
47 ;;; In general it should probably only be used on code that prepares for a | |
48 ;;; test, not on tests. | |
1095 | 49 ;;; |
428 | 50 ;;; You run the tests using M-x test-emacs-test-file, |
5069
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
51 ;;; or $(EMACS) -batch -l test-harness -f batch-test-emacs file ... |
428 | 52 ;;; which is run for you by the `make check' target in the top-level Makefile. |
53 | |
54 (require 'bytecomp) | |
55 | |
3471 | 56 (defvar unexpected-test-suite-failures 0 |
57 "Cumulative number of unexpected failures since test-harness was loaded. | |
58 | |
59 \"Unexpected failures\" are those caught by a generic handler established | |
60 outside of the test context. As such they involve an abort of the test | |
61 suite for the file being tested. | |
62 | |
63 They often occur during preparation of a test or recording of the results. | |
64 For example, an executable used to generate test data might not be present | |
65 on the system, or a system error might occur while reading a data file.") | |
66 | |
67 (defvar unexpected-test-suite-failure-files nil | |
68 "List of test files causing unexpected failures.") | |
69 | |
70 ;; Declared for dynamic scope; _do not_ initialize here. | |
71 (defvar unexpected-test-file-failures) | |
72 | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
73 (defvar test-harness-bug-expected nil |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
74 "Non-nil means a bug is expected; backtracing/debugging should not happen.") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
75 |
1758 | 76 (defvar test-harness-test-compiled nil |
4366
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
77 "Non-nil means the test code was compiled before execution. |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
78 |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
79 You probably should not make tests depend on compilation. |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
80 However, it can be useful to conditionally change messages based on whether |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
81 the code was compiled or not. For example, the case that motivated the |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
82 implementation of this variable: |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
83 |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
84 \(when test-harness-test-compiled |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
85 ;; this ha-a-ack depends on the failing compiled test coming last |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
86 \(setq test-harness-failure-tag |
7b628daa39d4
Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4323
diff
changeset
|
87 \"KNOWN BUG - fix reverted; after 2003-10-31 notify stephen\n\"))") |
1758 | 88 |
428 | 89 (defvar test-harness-verbose |
90 (and (not noninteractive) (> (device-baud-rate) search-slow-speed)) | |
91 "*Non-nil means print messages describing progress of emacs-tester.") | |
92 | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
93 (defvar test-harness-unexpected-error-enter-debugger debug-on-error |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
94 "*Non-nil means enter debugger when an unexpected error occurs. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
95 Only applies interactively. Normally true if `debug-on-error' has been set. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
96 See also `test-harness-assertion-failure-enter-debugger' and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
97 `test-harness-unexpected-error-show-backtrace'.") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
98 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
99 (defvar test-harness-assertion-failure-enter-debugger debug-on-error |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
100 "*Non-nil means enter debugger when an assertion failure occurs. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
101 Only applies interactively. Normally true if `debug-on-error' has been set. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
102 See also `test-harness-unexpected-error-enter-debugger' and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
103 `test-harness-assertion-failure-show-backtrace'.") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
104 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
105 (defvar test-harness-unexpected-error-show-backtrace t |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
106 "*Non-nil means show backtrace upon unexpected error. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
107 Only applies when debugger is not entered. Normally true by default. See also |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
108 `test-harness-unexpected-error-enter-debugger' and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
109 `test-harness-assertion-failure-show-backtrace'.") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
110 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
111 (defvar test-harness-assertion-failure-show-backtrace stack-trace-on-error |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
112 "*Non-nil means show backtrace upon assertion failure. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
113 Only applies when debugger is not entered. Normally true if |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
114 `stack-trace-on-error' has been set. See also |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
115 `test-harness-assertion-failure-enter-debugger' and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
116 `test-harness-unexpected-error-show-backtrace'.") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
117 |
1719 | 118 (defvar test-harness-file-results-alist nil |
119 "Each element is a list (FILE SUCCESSES TESTS). | |
120 The order is the reverse of the order in which tests are run. | |
121 | |
122 FILE is a string naming the test file. | |
123 SUCCESSES is a non-negative integer, the number of successes. | |
124 TESTS is a non-negative integer, the number of tests run.") | |
125 | |
1425 | 126 (defvar test-harness-risk-infloops nil |
127 "*Non-nil to run tests that may loop infinitely in buggy implementations.") | |
128 | |
428 | 129 (defvar test-harness-current-file nil) |
130 | |
131 (defvar emacs-lisp-file-regexp (purecopy "\\.el\\'") | |
132 "*Regexp which matches Emacs Lisp source files.") | |
133 | |
1751 | 134 (defconst test-harness-file-summary-template |
135 (format "%%-%ds %%%dd of %%%dd tests successful (%%3d%%%%)." | |
136 (length "byte-compiler-tests.el:") ; use the longest file name | |
137 5 | |
138 5) | |
139 "Format for summary lines printed after each file is run.") | |
140 | |
141 (defconst test-harness-null-summary-template | |
142 (format "%%-%ds No tests run." | |
143 (length "byte-compiler-tests.el:")) ; use the longest file name | |
144 "Format for \"No tests\" lines printed after a file is run.") | |
145 | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
146 (defconst test-harness-aborted-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
147 (format "%%-%ds %%%dd tests completed (aborted)." |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
148 (length "byte-compiler-tests.el:") ; use the longest file name |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
149 5) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
150 "Format for summary lines printed after a test run on a file was aborted.") |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
151 |
428 | 152 ;;;###autoload |
153 (defun test-emacs-test-file (filename) | |
154 "Test a file of Lisp code named FILENAME. | |
155 The output file's name is made by appending `c' to the end of FILENAME." | |
156 (interactive | |
157 (let ((file buffer-file-name) | |
158 (file-name nil) | |
159 (file-dir nil)) | |
160 (and file | |
161 (eq (cdr (assq 'major-mode (buffer-local-variables))) | |
162 'emacs-lisp-mode) | |
163 (setq file-name (file-name-nondirectory file) | |
164 file-dir (file-name-directory file))) | |
165 (list (read-file-name "Test file: " file-dir nil nil file-name)))) | |
166 ;; Expand now so we get the current buffer's defaults | |
167 (setq filename (expand-file-name filename)) | |
168 | |
169 ;; If we're testing a file that's in a buffer and is modified, offer | |
170 ;; to save it first. | |
171 (or noninteractive | |
172 (let ((b (get-file-buffer (expand-file-name filename)))) | |
173 (if (and b (buffer-modified-p b) | |
174 (y-or-n-p (format "save buffer %s first? " (buffer-name b)))) | |
175 (save-excursion (set-buffer b) (save-buffer))))) | |
176 | |
177 (if (or noninteractive test-harness-verbose) | |
178 (message "Testing %s..." filename)) | |
179 (let ((test-harness-current-file filename) | |
180 input-buffer) | |
181 (save-excursion | |
182 (setq input-buffer (get-buffer-create " *Test Input*")) | |
183 (set-buffer input-buffer) | |
184 (erase-buffer) | |
185 (insert-file-contents filename) | |
186 ;; Run hooks including the uncompression hook. | |
187 ;; If they change the file name, then change it for the output also. | |
188 (let ((buffer-file-name filename) | |
189 (default-major-mode 'emacs-lisp-mode) | |
190 (enable-local-eval nil)) | |
191 (normal-mode) | |
192 (setq filename buffer-file-name))) | |
193 (test-harness-from-buffer input-buffer filename) | |
194 (kill-buffer input-buffer) | |
195 )) | |
196 | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
197 (defsubst test-harness-assertion-failure-do-debug (error-info) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
198 "Maybe enter debugger or display a backtrace on assertion failure. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
199 ERROR-INFO is a cons of the args (SIG . DATA) that were passed to `signal'. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
200 The debugger will be entered if noninteractive and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
201 `test-harness-unexpected-error-enter-debugger' is non-nil; else, a |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
202 backtrace will be displayed if `test-harness-unexpected-error-show-backtrace' |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
203 is non-nil." |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
204 (when (not test-harness-bug-expected) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
205 (cond ((and (not noninteractive) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
206 test-harness-assertion-failure-enter-debugger) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
207 (funcall debugger 'error error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
208 (test-harness-assertion-failure-show-backtrace |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
209 (backtrace nil t))))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
210 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
211 (defsubst test-harness-unexpected-error-do-debug (error-info) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
212 "Maybe enter debugger or display a backtrace on unexpected error. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
213 ERROR-INFO is a cons of the args (SIG . DATA) that were passed to `signal'. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
214 The debugger will be entered if noninteractive and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
215 `test-harness-unexpected-error-enter-debugger' is non-nil; else, a |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
216 backtrace will be displayed if `test-harness-unexpected-error-show-backtrace' |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
217 is non-nil." |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
218 (when (not test-harness-bug-expected) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
219 (cond ((and (not noninteractive) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
220 test-harness-unexpected-error-enter-debugger) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
221 (funcall debugger 'error error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
222 (test-harness-unexpected-error-show-backtrace |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
223 (backtrace nil t))))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
224 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
225 (defsubst test-harness-unexpected-error-condition-handler (error-info context-msg) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
226 "Condition handler for when unexpected errors occur. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
227 Useful in conjunction with `call-with-condition-handler'. ERROR-INFO is the |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
228 value passed to the condition handler. CONTEXT-MSG is a string indicating |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
229 the context in which the unexpected error occurred. A message is outputted |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
230 including CONTEXT-MSG in it, `unexpected-test-file-failures' is incremented, |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
231 and `test-harness-unexpected-error-do-debug' is called, which may enter the |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
232 debugger or output a backtrace, depending on the settings of |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
233 `test-harness-unexpected-error-enter-debugger' and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
234 `test-harness-unexpected-error-show-backtrace'. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
235 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
236 The function returns normally, which causes error-handling processing to |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
237 continue; if you want to catch the error, you also need to wrap everything |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
238 in `condition-case'. See also `test-harness-error-wrap', which does this |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
239 wrapping." |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
240 (incf unexpected-test-file-failures) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
241 (princ (format "Unexpected error %S while %s\n" |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
242 error-info context-msg)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
243 (message "Unexpected error %S while %s." error-info context-msg) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
244 (test-harness-unexpected-error-do-debug error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
245 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
246 (defmacro test-harness-error-wrap (context-msg abort-msg &rest body) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
247 "Wrap BODY so that unexpected errors are caught. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
248 The debugger will be entered if noninteractive and |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
249 `test-harness-unexpected-error-enter-debugger' is non-nil; else, a backtrace |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
250 will be displayed if `test-harness-unexpected-error-show-backtrace' is |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
251 non-nil. CONTEXT-MSG is displayed as part of a message shown before entering |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
252 the debugger or showing a backtrace, and ABORT-MSG, if non-nil, is displayed |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
253 afterwards. See " |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
254 `(condition-case nil |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
255 (call-with-condition-handler |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
256 #'(lambda (error-info) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
257 (test-harness-unexpected-error-condition-handler |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
258 error-info ,context-msg)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
259 #'(lambda () |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
260 ,@body)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
261 (error ,(if abort-msg `(message ,abort-msg) nil)))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
262 |
428 | 263 (defun test-harness-read-from-buffer (buffer) |
264 "Read forms from BUFFER, and turn it into a lambda test form." | |
265 (let ((body nil)) | |
266 (goto-char (point-min) buffer) | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
267 (condition-case nil |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
268 (call-with-condition-handler |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
269 #'(lambda (error-info) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
270 ;; end-of-file is expected, so don't output error or backtrace |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
271 ;; or enter debugger in this case. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
272 (unless (eq 'end-of-file (car error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
273 (test-harness-unexpected-error-condition-handler |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
274 error-info "reading forms from buffer"))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
275 #'(lambda () |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
276 (while t |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
277 (setq body (cons (read buffer) body))))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
278 (error nil)) |
428 | 279 `(lambda () |
280 (defvar passes) | |
281 (defvar assertion-failures) | |
282 (defvar no-error-failures) | |
283 (defvar wrong-error-failures) | |
284 (defvar missing-message-failures) | |
285 (defvar other-failures) | |
286 | |
287 (defvar trick-optimizer) | |
288 | |
289 ,@(nreverse body)))) | |
290 | |
291 (defun test-harness-from-buffer (inbuffer filename) | |
292 "Run tests in buffer INBUFFER, visiting FILENAME." | |
293 (defvar trick-optimizer) | |
294 (let ((passes 0) | |
295 (assertion-failures 0) | |
296 (no-error-failures 0) | |
297 (wrong-error-failures 0) | |
298 (missing-message-failures 0) | |
299 (other-failures 0) | |
3471 | 300 (unexpected-test-file-failures 0) |
428 | 301 |
973 | 302 ;; #### perhaps this should be a defvar, and output at the very end |
303 ;; OTOH, this way AC types can use a null EMACSPACKAGEPATH to find | |
304 ;; what stuff is needed, and ways to avoid using them | |
305 (skipped-test-reasons (make-hash-table :test 'equal)) | |
306 | |
428 | 307 (trick-optimizer nil) |
826 | 308 (debug-on-error t) |
5064
501b5e84f5a7
remove unused var in test-harness
Ben Wing <ben@xemacs.org>
parents:
5040
diff
changeset
|
309 ) |
428 | 310 (with-output-to-temp-buffer "*Test-Log*" |
826 | 311 (princ (format "Testing %s...\n\n" filename)) |
1095 | 312 |
1413 | 313 (defconst test-harness-failure-tag "FAIL") |
314 (defconst test-harness-success-tag "PASS") | |
1095 | 315 |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
316 ;;;;; BEGIN DEFINITION OF MACROS USEFUL IN TEST CODE |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
317 |
1095 | 318 (defmacro Known-Bug-Expect-Failure (&rest body) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
319 "Wrap a BODY that consists of tests that are known to fail. |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
320 This causes messages to be printed on failure indicating that this is expected, |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
321 and on success indicating that this is unexpected." |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
322 `(let ((test-harness-bug-expected t) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
323 (test-harness-failure-tag "KNOWN BUG") |
1413 | 324 (test-harness-success-tag "PASS (FAILURE EXPECTED)")) |
325 ,@body)) | |
4323
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
326 |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
327 (defmacro Known-Bug-Expect-Error (expected-error &rest body) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
328 "Wrap a BODY that consists of tests that are known to trigger an error. |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
329 This causes messages to be printed on failure indicating that this is expected, |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
330 and on success indicating that this is unexpected." |
4323
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
331 (let ((quoted-body (if (= 1 (length body)) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
332 `(quote ,(car body)) `(quote (progn ,@body))))) |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
333 `(let ((test-harness-bug-expected t) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
334 (test-harness-failure-tag "KNOWN BUG") |
4323
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
335 (test-harness-success-tag "PASS (FAILURE EXPECTED)")) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
336 (condition-case error-info |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
337 (progn |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
338 (setq trick-optimizer (progn ,@body)) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
339 (Print-Pass |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
340 "%S executed successfully, but expected error %S" |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
341 ,quoted-body |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
342 ',expected-error) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
343 (incf passes)) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
344 (,expected-error |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
345 (Print-Failure "%S ==> error %S, as expected" |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
346 ,quoted-body ',expected-error) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
347 (incf no-error-failures)) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
348 (error |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
349 (Print-Failure "%S ==> expected error %S, got error %S instead" |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
350 ,quoted-body ',expected-error error-info) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
351 (incf wrong-error-failures)))))) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
352 |
1413 | 353 (defmacro Implementation-Incomplete-Expect-Failure (&rest body) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
354 "Wrap a BODY containing tests that are known to fail due to incomplete code. |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
355 This causes messages to be printed on failure indicating that the |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
356 implementation is incomplete (and hence the failure is expected); and on |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
357 success indicating that this is unexpected." |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
358 `(let ((test-harness-bug-expected t) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
359 (test-harness-failure-tag "IMPLEMENTATION INCOMPLETE") |
1413 | 360 (test-harness-success-tag "PASS (FAILURE EXPECTED)")) |
361 ,@body)) | |
826 | 362 |
363 (defun Print-Failure (fmt &rest args) | |
1413 | 364 (setq fmt (format "%s: %s" test-harness-failure-tag fmt)) |
826 | 365 (if (noninteractive) (apply #'message fmt args)) |
366 (princ (concat (apply #'format fmt args) "\n"))) | |
367 | |
368 (defun Print-Pass (fmt &rest args) | |
1413 | 369 (setq fmt (format "%s: %s" test-harness-success-tag fmt)) |
826 | 370 (and test-harness-verbose |
371 (princ (concat (apply #'format fmt args) "\n")))) | |
372 | |
973 | 373 (defun Print-Skip (test reason &optional fmt &rest args) |
1095 | 374 (setq fmt (concat "SKIP: %S BECAUSE %S" fmt)) |
973 | 375 (princ (concat (apply #'format fmt test reason args) "\n"))) |
376 | |
1095 | 377 (defmacro Skip-Test-Unless (condition reason description &rest body) |
378 "Unless CONDITION is satisfied, skip test BODY. | |
379 REASON is a description of the condition failure, and must be unique (it | |
380 is used as a hash key). DESCRIPTION describes the tests that were skipped. | |
381 BODY is a sequence of expressions and may contain several tests." | |
382 `(if (not ,condition) | |
383 (let ((count (gethash ,reason skipped-test-reasons))) | |
384 (puthash ,reason (if (null count) 1 (1+ count)) | |
385 skipped-test-reasons) | |
386 (Print-Skip ,description ,reason)) | |
387 ,@body)) | |
428 | 388 |
4747
294a86d29f99
Eliminate C asserts from c-tests.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4415
diff
changeset
|
389 (defmacro Assert (assertion &optional failing-case description) |
294a86d29f99
Eliminate C asserts from c-tests.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4415
diff
changeset
|
390 "Test passes if ASSERTION is true. |
4856 | 391 Optional FAILING-CASE describes the particular failure. Optional |
392 DESCRIPTION describes the assertion; by default, the unevalated assertion | |
393 expression is given. FAILING-CASE and DESCRIPTION are useful when Assert | |
394 is used in a loop." | |
395 (let ((description | |
396 (or description `(quote ,assertion)))) | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
397 `(condition-case nil |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
398 (call-with-condition-handler |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
399 #'(lambda (error-info) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
400 (if (eq 'cl-assertion-failed (car error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
401 (progn |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
402 (Print-Failure |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
403 (if ,failing-case |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
404 "Assertion failed: %S; failing case = %S" |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
405 "Assertion failed: %S") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
406 ,description ,failing-case) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
407 (incf assertion-failures) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
408 (test-harness-assertion-failure-do-debug error-info)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
409 (Print-Failure |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
410 (if ,failing-case |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
411 "%S ==> error: %S; failing case = %S" |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
412 "%S ==> error: %S") |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
413 ,description error-info ,failing-case) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
414 (incf other-failures) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
415 (test-harness-unexpected-error-do-debug error-info))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
416 #'(lambda () |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
417 (assert ,assertion) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
418 (Print-Pass "%S" ,description) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
419 (incf passes))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
420 (cl-assertion-failed nil)))) |
2056 | 421 |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
422 ;;;;; BEGIN DEFINITION OF SPECIFIC KINDS OF ASSERT MACROS |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
423 |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
424 (defmacro Assert-test (test testval expected &optional failing-case |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
425 description) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
426 "Test passes if TESTVAL compares correctly to EXPECTED using TEST. |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
427 TEST should be a two-argument predicate (i.e. a function of two arguments |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
428 that returns t or nil), such as `eq', `eql', `equal', `equalp', `=', `<=', |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
429 '>', 'file-newer-than-file-p' etc. Optional FAILING-CASE describes the |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
430 particular failure; any value given here will be concatenated with a phrase |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
431 describing the expected and actual values of the comparison. Optional |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
432 DESCRIPTION describes the assertion; by default, the unevalated comparison |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
433 expressions are given. FAILING-CASE and DESCRIPTION are useful when Assert |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
434 is used in a loop." |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
435 (let* ((assertion `(,test ,testval ,expected)) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
436 (failmsg `(format "%S should be `%s' to %S but isn't" |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
437 ,testval ',test ,expected)) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
438 (failmsg2 (if failing-case `(concat |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
439 (format "%S, " ,failing-case) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
440 ,failmsg) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
441 failmsg))) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
442 `(Assert ,assertion ,failmsg2 ,description))) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
443 |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
444 (defmacro Assert-test-not (test testval expected &optional failing-case |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
445 description) |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
446 "Test passes if TESTVAL does not compare correctly to EXPECTED using TEST. |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
447 TEST should be a two-argument predicate (i.e. a function of two arguments |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
448 that returns t or nil), such as `eq', `eql', `equal', `equalp', `=', `<=', |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
449 '>', 'file-newer-than-file-p' etc. Optional FAILING-CASE describes the |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
450 particular failure; any value given here will be concatenated with a phrase |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
451 describing the expected and actual values of the comparison. Optional |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
452 DESCRIPTION describes the assertion; by default, the unevalated comparison |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
453 expressions are given. FAILING-CASE and DESCRIPTION are useful when Assert |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
454 is used in a loop." |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
455 (let* ((assertion `(not (,test ,testval ,expected))) |
4891
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
456 (failmsg `(format "%S shouldn't be `%s' to %S but is" |
732c35cdded8
fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
457 ,testval ',test ,expected)) |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
458 (failmsg2 (if failing-case `(concat |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
459 (format "%S, " ,failing-case) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
460 ,failmsg) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
461 failmsg))) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
462 `(Assert ,assertion ,failmsg2 ,description))) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
463 |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
464 ;; Specific versions of `Assert-test'. These are just convenience |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
465 ;; functions, functioning identically to `Assert-test', and duplicating |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
466 ;; the doc string for each would be too annoying. |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
467 (defmacro Assert-eq (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
468 description) |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
469 `(Assert-test eq ,testval ,expected ,failing-case ,description)) |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
470 (defmacro Assert-eql (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
471 description) |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
472 `(Assert-test eql ,testval ,expected ,failing-case ,description)) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
473 (defmacro Assert-equal (testval expected &optional failing-case |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
474 description) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
475 `(Assert-test equal ,testval ,expected ,failing-case ,description)) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
476 (defmacro Assert-equalp (testval expected &optional failing-case |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
477 description) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
478 `(Assert-test equalp ,testval ,expected ,failing-case ,description)) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
479 (defmacro Assert-string= (testval expected &optional failing-case |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
480 description) |
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
481 `(Assert-test string= ,testval ,expected ,failing-case ,description)) |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
482 (defmacro Assert= (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
483 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
484 `(Assert-test = ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
485 (defmacro Assert<= (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
486 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
487 `(Assert-test <= ,testval ,expected ,failing-case ,description)) |
4855
189fb67ca31a
Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents:
4845
diff
changeset
|
488 |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
489 ;; Specific versions of `Assert-test-not'. These are just convenience |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
490 ;; functions, functioning identically to `Assert-test-not', and |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
491 ;; duplicating the doc string for each would be too annoying. |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
492 (defmacro Assert-not-eq (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
493 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
494 `(Assert-test-not eq ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
495 (defmacro Assert-not-eql (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
496 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
497 `(Assert-test-not eql ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
498 (defmacro Assert-not-equal (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
499 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
500 `(Assert-test-not equal ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
501 (defmacro Assert-not-equalp (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
502 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
503 `(Assert-test-not equalp ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
504 (defmacro Assert-not-string= (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
505 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
506 `(Assert-test-not string= ,testval ,expected ,failing-case ,description)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
507 (defmacro Assert-not= (testval expected &optional failing-case |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
508 description) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
509 `(Assert-test-not = ,testval ,expected ,failing-case ,description)) |
428 | 510 |
511 (defmacro Check-Error (expected-error &rest body) | |
512 (let ((quoted-body (if (= 1 (length body)) | |
513 `(quote ,(car body)) `(quote (progn ,@body))))) | |
514 `(condition-case error-info | |
515 (progn | |
516 (setq trick-optimizer (progn ,@body)) | |
826 | 517 (Print-Failure "%S executed successfully, but expected error %S" |
428 | 518 ,quoted-body |
826 | 519 ',expected-error) |
428 | 520 (incf no-error-failures)) |
521 (,expected-error | |
826 | 522 (Print-Pass "%S ==> error %S, as expected" |
523 ,quoted-body ',expected-error) | |
428 | 524 (incf passes)) |
525 (error | |
826 | 526 (Print-Failure "%S ==> expected error %S, got error %S instead" |
527 ,quoted-body ',expected-error error-info) | |
428 | 528 (incf wrong-error-failures))))) |
529 | |
826 | 530 (defmacro Check-Error-Message (expected-error expected-error-regexp |
531 &rest body) | |
428 | 532 (let ((quoted-body (if (= 1 (length body)) |
533 `(quote ,(car body)) `(quote (progn ,@body))))) | |
534 `(condition-case error-info | |
535 (progn | |
536 (setq trick-optimizer (progn ,@body)) | |
826 | 537 (Print-Failure "%S executed successfully, but expected error %S" |
538 ,quoted-body ',expected-error) | |
428 | 539 (incf no-error-failures)) |
540 (,expected-error | |
4199 | 541 ;; #### Damn, this binding doesn't capture frobs, eg, for |
542 ;; invalid_argument() ... you only get the REASON. And for | |
543 ;; wrong_type_argument(), there's no reason only FROBs. | |
544 ;; If this gets fixed, fix tests in regexp-tests.el. | |
428 | 545 (let ((error-message (second error-info))) |
546 (if (string-match ,expected-error-regexp error-message) | |
547 (progn | |
826 | 548 (Print-Pass "%S ==> error %S %S, as expected" |
549 ,quoted-body error-message ',expected-error) | |
428 | 550 (incf passes)) |
826 | 551 (Print-Failure "%S ==> got error %S as expected, but error message %S did not match regexp %S" |
552 ,quoted-body ',expected-error error-message ,expected-error-regexp) | |
428 | 553 (incf wrong-error-failures)))) |
554 (error | |
826 | 555 (Print-Failure "%S ==> expected error %S, got error %S instead" |
556 ,quoted-body ',expected-error error-info) | |
428 | 557 (incf wrong-error-failures))))) |
558 | |
3472 | 559 ;; Do not use this with Silence-Message. |
428 | 560 (defmacro Check-Message (expected-message-regexp &rest body) |
5069
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
561 (let ((quoted-body (if (= 1 (length body)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
562 `(quote ,(car body)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
563 `(quote (progn ,@body))))) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
564 `(Skip-Test-Unless (fboundp 'defadvice) "can't defadvice" |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
565 expected-message-regexp |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
566 (let ((messages "")) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
567 (defadvice message (around collect activate) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
568 (defvar messages) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
569 (let ((msg-string (apply 'format (ad-get-args 0)))) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
570 (setq messages (concat messages msg-string)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
571 msg-string)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
572 (ignore-errors |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
573 (call-with-condition-handler |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
574 #'(lambda (error-info) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
575 (Print-Failure "%S ==> unexpected error %S" |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
576 ,quoted-body error-info) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
577 (incf other-failures) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
578 (test-harness-unexpected-error-do-debug error-info)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
579 #'(lambda () |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
580 (setq trick-optimizer (progn ,@body)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
581 (if (string-match ,expected-message-regexp messages) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
582 (progn |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
583 (Print-Pass |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
584 "%S ==> value %S, message %S, matching %S, as expected" |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
585 ,quoted-body trick-optimizer messages |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
586 ',expected-message-regexp) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
587 (incf passes)) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
588 (Print-Failure |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
589 "%S ==> value %S, message %S, NOT matching expected %S" |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
590 ,quoted-body trick-optimizer messages |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
591 ',expected-message-regexp) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
592 (incf missing-message-failures))))) |
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
593 (ad-unadvise 'message))))) |
428 | 594 |
3472 | 595 ;; #### Perhaps this should override `message' itself, too? |
596 (defmacro Silence-Message (&rest body) | |
4323
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
597 `(flet ((append-message (&rest args) ()) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
598 (clear-message (&rest args) ())) |
94509abd0ef0
Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
599 ,@body)) |
3472 | 600 |
428 | 601 (defmacro Ignore-Ebola (&rest body) |
602 `(let ((debug-issue-ebola-notices -42)) ,@body)) | |
603 | |
604 (defun Int-to-Marker (pos) | |
605 (save-excursion | |
606 (set-buffer standard-output) | |
607 (save-excursion | |
608 (goto-char pos) | |
609 (point-marker)))) | |
610 | |
611 (princ "Testing Interpreted Lisp\n\n") | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
612 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
613 (test-harness-error-wrap |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
614 "executing interpreted code" |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
615 "Test suite execution aborted." |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
616 (funcall (test-harness-read-from-buffer inbuffer))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
617 |
428 | 618 (princ "\nTesting Compiled Lisp\n\n") |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
619 |
1758 | 620 (let (code |
621 (test-harness-test-compiled t)) | |
5040
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
622 (test-harness-error-wrap |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
623 "byte-compiling code" nil |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
624 (setq code |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
625 ;; our lisp code is often intentionally dubious, |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
626 ;; so throw away _all_ the byte compiler warnings. |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
627 (letf (((symbol-function 'byte-compile-warn) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
628 'ignore)) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
629 (byte-compile (test-harness-read-from-buffer |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
630 inbuffer)))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
631 ) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
632 |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
633 (test-harness-error-wrap "executing byte-compiled code" |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
634 "Test suite execution aborted." |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
635 (if code (funcall code))) |
3daf9fc57cd4
fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
636 ) |
826 | 637 (princ (format "\nSUMMARY for %s:\n" filename)) |
428 | 638 (princ (format "\t%5d passes\n" passes)) |
639 (princ (format "\t%5d assertion failures\n" assertion-failures)) | |
640 (princ (format "\t%5d errors that should have been generated, but weren't\n" no-error-failures)) | |
641 (princ (format "\t%5d wrong-error failures\n" wrong-error-failures)) | |
642 (princ (format "\t%5d missing-message failures\n" missing-message-failures)) | |
643 (princ (format "\t%5d other failures\n" other-failures)) | |
644 (let* ((total (+ passes | |
645 assertion-failures | |
646 no-error-failures | |
647 wrong-error-failures | |
648 missing-message-failures | |
649 other-failures)) | |
650 (basename (file-name-nondirectory filename)) | |
651 (summary-msg | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
652 (cond ((> unexpected-test-file-failures 0) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
653 (format test-harness-aborted-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
654 (concat basename ":") total)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
655 ((> total 0) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
656 (format test-harness-file-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
657 (concat basename ":") |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
658 passes total (/ (* 100 passes) total))) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
659 (t |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
660 (format test-harness-null-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
661 (concat basename ":"))))) |
973 | 662 (reasons "")) |
663 (maphash (lambda (key value) | |
664 (setq reasons | |
665 (concat reasons | |
1095 | 666 (format "\n %d tests skipped because %s." |
973 | 667 value key)))) |
668 skipped-test-reasons) | |
669 (when (> (length reasons) 1) | |
670 (setq summary-msg (concat summary-msg reasons " | |
4415
bceb3e285ae7
case-tests.el: fix it on non-DEBUG_XEMACS; save standard-case-table, use it
Aidan Kehoe <kehoea@parhasard.net>
parents:
4366
diff
changeset
|
671 It may be that XEmacs cannot find your installed packages. Set |
bceb3e285ae7
case-tests.el: fix it on non-DEBUG_XEMACS; save standard-case-table, use it
Aidan Kehoe <kehoea@parhasard.net>
parents:
4366
diff
changeset
|
672 EMACSPACKAGEPATH to the package hierarchy root or configure with |
bceb3e285ae7
case-tests.el: fix it on non-DEBUG_XEMACS; save standard-case-table, use it
Aidan Kehoe <kehoea@parhasard.net>
parents:
4366
diff
changeset
|
673 --package-path to enable the skipped tests."))) |
1719 | 674 (setq test-harness-file-results-alist |
675 (cons (list filename passes total) | |
676 test-harness-file-results-alist)) | |
428 | 677 (message "%s" summary-msg)) |
3471 | 678 (when (> unexpected-test-file-failures 0) |
679 (setq unexpected-test-suite-failure-files | |
680 (cons filename unexpected-test-suite-failure-files)) | |
681 (setq unexpected-test-suite-failures | |
682 (+ unexpected-test-suite-failures unexpected-test-file-failures)) | |
428 | 683 (message "Test suite execution failed unexpectedly.")) |
684 (fmakunbound 'Assert) | |
685 (fmakunbound 'Check-Error) | |
863 | 686 (fmakunbound 'Check-Message) |
687 (fmakunbound 'Check-Error-Message) | |
428 | 688 (fmakunbound 'Ignore-Ebola) |
689 (fmakunbound 'Int-to-Marker) | |
1719 | 690 (and noninteractive |
691 (message "%s" (buffer-substring-no-properties | |
1751 | 692 nil nil "*Test-Log*"))) |
693 ))) | |
428 | 694 |
695 (defvar test-harness-results-point-max nil) | |
696 (defmacro displaying-emacs-test-results (&rest body) | |
697 `(let ((test-harness-results-point-max test-harness-results-point-max)) | |
698 ;; Log the file name. | |
699 (test-harness-log-file) | |
700 ;; Record how much is logged now. | |
701 ;; We will display the log buffer if anything more is logged | |
702 ;; before the end of BODY. | |
703 (or test-harness-results-point-max | |
704 (save-excursion | |
705 (set-buffer (get-buffer-create "*Test-Log*")) | |
706 (setq test-harness-results-point-max (point-max)))) | |
707 (unwind-protect | |
708 (condition-case error-info | |
709 (progn ,@body) | |
710 (error | |
711 (test-harness-report-error error-info))) | |
712 (save-excursion | |
713 ;; If there were compilation warnings, display them. | |
714 (set-buffer "*Test-Log*") | |
715 (if (= test-harness-results-point-max (point-max)) | |
716 nil | |
717 (if temp-buffer-show-function | |
718 (let ((show-buffer (get-buffer-create "*Test-Log-Show*"))) | |
719 (save-excursion | |
720 (set-buffer show-buffer) | |
721 (setq buffer-read-only nil) | |
722 (erase-buffer)) | |
723 (copy-to-buffer show-buffer | |
724 (save-excursion | |
725 (goto-char test-harness-results-point-max) | |
726 (forward-line -1) | |
727 (point)) | |
728 (point-max)) | |
729 (funcall temp-buffer-show-function show-buffer)) | |
730 (select-window | |
731 (prog1 (selected-window) | |
732 (select-window (display-buffer (current-buffer))) | |
733 (goto-char test-harness-results-point-max) | |
734 (recenter 1))))))))) | |
735 | |
736 (defun batch-test-emacs-1 (file) | |
737 (condition-case error-info | |
738 (progn (test-emacs-test-file file) t) | |
739 (error | |
740 (princ ">>Error occurred processing ") | |
741 (princ file) | |
742 (princ ": ") | |
743 (display-error error-info nil) | |
744 (terpri) | |
745 nil))) | |
746 | |
747 (defun batch-test-emacs () | |
748 "Run `test-harness' on the files remaining on the command line. | |
749 Use this from the command line, with `-batch'; | |
750 it won't work in an interactive Emacs. | |
751 Each file is processed even if an error occurred previously. | |
5069
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
752 A directory can be given as well, and all files will be processed. |
4948
8b230c53075b
fix some tests in `make check', also add our own file-tests
Ben Wing <ben@xemacs.org>
parents:
4856
diff
changeset
|
753 For example, invoke \"xemacs -batch -f batch-test-emacs tests\"" |
428 | 754 ;; command-line-args-left is what is left of the command line (from |
755 ;; startup.el) | |
756 (defvar command-line-args-left) ;Avoid 'free variable' warning | |
757 (defvar debug-issue-ebola-notices) | |
758 (if (not noninteractive) | |
759 (error "`batch-test-emacs' is to be used only with -batch")) | |
760 (let ((error nil)) | |
761 (dolist (file command-line-args-left) | |
762 (if (file-directory-p file) | |
763 (dolist (file-in-dir (directory-files file t)) | |
764 (when (and (string-match emacs-lisp-file-regexp file-in-dir) | |
765 (not (or (auto-save-file-name-p file-in-dir) | |
5069
14f0dd1fabdb
move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents:
5064
diff
changeset
|
766 (backup-file-name-p file-in-dir)))) |
428 | 767 (or (batch-test-emacs-1 file-in-dir) |
768 (setq error t)))) | |
769 (or (batch-test-emacs-1 file) | |
770 (setq error t)))) | |
1719 | 771 (let ((namelen 0) |
772 (succlen 0) | |
773 (testlen 0) | |
774 (results test-harness-file-results-alist)) | |
775 ;; compute maximum lengths of variable components of report | |
776 ;; probably should just use (length "byte-compiler-tests.el") | |
777 ;; and 5-place sizes -- this will also work for the file-by-file | |
778 ;; printing when Adrian's kludge gets reverted | |
779 (flet ((print-width (i) | |
780 (let ((x 10) (y 1)) | |
781 (while (>= i x) | |
782 (setq x (* 10 x) y (1+ y))) | |
783 y))) | |
784 (while results | |
785 (let* ((head (car results)) | |
786 (nn (length (file-name-nondirectory (first head)))) | |
787 (ss (print-width (second head))) | |
788 (tt (print-width (third head)))) | |
789 (when (> nn namelen) (setq namelen nn)) | |
790 (when (> ss succlen) (setq succlen ss)) | |
791 (when (> tt testlen) (setq testlen tt))) | |
792 (setq results (cdr results)))) | |
793 ;; create format and print | |
1751 | 794 (let ((results (reverse test-harness-file-results-alist))) |
1719 | 795 (while results |
796 (let* ((head (car results)) | |
1751 | 797 (basename (file-name-nondirectory (first head))) |
1719 | 798 (nsucc (second head)) |
799 (ntest (third head))) | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
800 (cond ((member (first head) unexpected-test-suite-failure-files) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
801 (message test-harness-aborted-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
802 (concat basename ":") |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
803 ntest)) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
804 ((> ntest 0) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
805 (message test-harness-file-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
806 (concat basename ":") |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
807 nsucc |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
808 ntest |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
809 (/ (* 100 nsucc) ntest))) |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
810 (t |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
811 (message test-harness-null-summary-template |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4891
diff
changeset
|
812 (concat basename ":")))) |
3471 | 813 (setq results (cdr results))))) |
814 (when (> unexpected-test-suite-failures 0) | |
815 (message "\n***** There %s %d unexpected test suite %s in %s:" | |
816 (if (= unexpected-test-suite-failures 1) "was" "were") | |
817 unexpected-test-suite-failures | |
818 (if (= unexpected-test-suite-failures 1) "failure" "failures") | |
819 (if (= (length unexpected-test-suite-failure-files) 1) | |
820 "file" | |
821 "files")) | |
822 (while unexpected-test-suite-failure-files | |
823 (let ((line (pop unexpected-test-suite-failure-files))) | |
824 (while (and (< (length line) 61) | |
825 unexpected-test-suite-failure-files) | |
826 (setq line | |
827 (concat line " " | |
828 (pop unexpected-test-suite-failure-files)))) | |
829 (message line))))) | |
1719 | 830 (message "\nDone") |
428 | 831 (kill-emacs (if error 1 0)))) |
832 | |
833 (provide 'test-harness) | |
834 | |
835 ;;; test-harness.el ends here |