annotate lisp/test-harness.el @ 5602:c9e5612f5424

Support the MP library on recent FreeBSD, have it pass relevant tests. src/ChangeLog addition: 2011-11-26 Aidan Kehoe <kehoea@parhasard.net> * number-mp.c (bignum_to_string): Don't overwrite the accumulator we've just set up for this function. * number-mp.c (BIGNUM_TO_TYPE): mp_itom() doesn't necessarily do what this code used to think with negative numbers, it can treat them as unsigned ints. Subtract numbers from bignum_zero instead of multiplying them by -1 to convert them to their negative equivalents. * number-mp.c (bignum_to_int): * number-mp.c (bignum_to_uint): * number-mp.c (bignum_to_long): * number-mp.c (bignum_to_ulong): * number-mp.c (bignum_to_double): Use the changed BIGNUM_TO_TYPE() in these functions. * number-mp.c (bignum_ceil): * number-mp.c (bignum_floor): In these functions, be more careful about rounding to positive and negative infinity, respectively. Don't use the sign of QUOTIENT when working out out whether to add or subtract one, rather use the sign QUOTIENT would have if arbitrary-precision division were done. * number-mp.h: * number-mp.h (MP_GCD): Wrap #include <mp.h> in BEGIN_C_DECLS/END_C_DECLS. * number.c (Fbigfloat_get_precision): * number.c (Fbigfloat_set_precision): Don't attempt to call XBIGFLOAT_GET_PREC if this build doesn't support big floats.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 26 Nov 2011 17:59:14 +0000
parents 3bc58dc9d688
children
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
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
3 ;;; Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
4856
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
4 ;;; Copyright (C) 2002, 2010 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
1761
db7c7e251153 [xemacs-hg @ 2003-10-23 12:48:45 by stephent]
stephent
parents: 1758
diff changeset
7 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: testing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
12 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
14 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
15 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
20 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5274
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; A test suite harness for testing XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;;; The actual tests are in other files in this directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;; 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
32 ;;; 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
33 ;;; 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
34 ;;; Don't suppress tests just because they're due to known bugs not yet
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
35 ;;; fixed -- use the Known-Bug-Expect-Failure and
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
36 ;;; Implementation-Incomplete-Expect-Failure wrapper macros to mark them.
1095
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.
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
39 ;;; Some noisy code will call `message'. Output from `message' can be
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
40 ;;; suppressed with the Silence-Message macro. Functions that are known to
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
41 ;;; issue messages include `write-region', `find-tag', `tag-loop-continue',
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
42 ;;; `insert', and `mark-whole-buffer'. N.B. The Silence-Message macro
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
43 ;;; currently does not suppress the newlines printed by `message'.
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
44 ;;; Definitely do not use Silence-Message with Check-Message.
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
45 ;;; In general it should probably only be used on code that prepares for a
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
46 ;;; test, not on tests.
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
47 ;;;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 ;;; 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
49 ;;; or $(EMACS) -batch -l test-harness -f batch-test-emacs file ...
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;;; 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
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (require 'bytecomp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
54 (defvar unexpected-test-suite-failures 0
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
55 "Cumulative number of unexpected failures since test-harness was loaded.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
56
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
57 \"Unexpected failures\" are those caught by a generic handler established
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
58 outside of the test context. As such they involve an abort of the test
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
59 suite for the file being tested.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
60
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
61 They often occur during preparation of a test or recording of the results.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
62 For example, an executable used to generate test data might not be present
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
63 on the system, or a system error might occur while reading a data file.")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
64
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
65 (defvar unexpected-test-suite-failure-files nil
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
66 "List of test files causing unexpected failures.")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
67
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
68 ;; Declared for dynamic scope; _do not_ initialize here.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
69 (defvar unexpected-test-file-failures)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
70
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
71 (defvar test-harness-bug-expected nil
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
72 "Non-nil means a bug is expected; backtracing/debugging should not happen.
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
73 However, the individual test summary should be printed.")
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
74
1758
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
75 (defvar test-harness-test-compiled nil
4366
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
76 "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
77
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
78 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
79 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
80 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
81 implementation of this variable:
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
82
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
83 \(when test-harness-test-compiled
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
84 ;; 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
85 \(setq test-harness-failure-tag
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
86 \"KNOWN BUG - fix reverted; after 2003-10-31 notify stephen\n\"))")
1758
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
87
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defvar test-harness-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (and (not noninteractive) (> (device-baud-rate) search-slow-speed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 "*Non-nil means print messages describing progress of emacs-tester.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
92 (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
93 "*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
94 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
95 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
96 `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
97
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
98 (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
99 "*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
100 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
101 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
102 `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
103
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
104 (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
105 "*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
106 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
107 `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
108 `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
109
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
110 (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
111 "*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
112 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
113 `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
114 `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
115 `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
116
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
117 (defvar test-harness-file-results-alist nil
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
118 "Each element is a list (FILE SUCCESSES TESTS).
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
119 The order is the reverse of the order in which tests are run.
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
120
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
121 FILE is a string naming the test file.
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
122 SUCCESSES is a non-negative integer, the number of successes.
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
123 TESTS is a non-negative integer, the number of tests run.")
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
124
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
125 (defvar test-harness-risk-infloops nil
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
126 "*Non-nil to run tests that may loop infinitely in buggy implementations.")
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
127
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (defvar test-harness-current-file nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
5369
4141aeddc55b Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5366
diff changeset
130 (defvar emacs-lisp-file-regexp "\\.el\\'"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 "*Regexp which matches Emacs Lisp source files.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
133 (defconst test-harness-file-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
134 (format "%%-%ds %%%dd of %%%dd tests successful (%%3d%%%%)."
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
135 (length "byte-compiler-tests.el:") ; use the longest file name
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
136 5
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
137 5)
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
138 "Format for summary lines printed after each file is run.")
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
139
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
140 (defconst test-harness-null-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
141 (format "%%-%ds No tests run."
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
142 (length "byte-compiler-tests.el:")) ; use the longest file name
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
143 "Format for \"No tests\" lines printed after a file is run.")
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
144
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
145 (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
146 (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
147 (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
148 5)
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
149 "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
150
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (defun test-emacs-test-file (filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 "Test a file of Lisp code named FILENAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 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
155 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (let ((file buffer-file-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (file-name nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (file-dir nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (and file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (eq (cdr (assq 'major-mode (buffer-local-variables)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 'emacs-lisp-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (setq file-name (file-name-nondirectory file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 file-dir (file-name-directory file)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (list (read-file-name "Test file: " file-dir nil nil file-name))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ;; Expand now so we get the current buffer's defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (setq filename (expand-file-name filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 ;; 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
169 ;; to save it first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (or noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (let ((b (get-file-buffer (expand-file-name filename))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (if (and b (buffer-modified-p b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (y-or-n-p (format "save buffer %s first? " (buffer-name b))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (save-excursion (set-buffer b) (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (if (or noninteractive test-harness-verbose)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (message "Testing %s..." filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (let ((test-harness-current-file filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (setq input-buffer (get-buffer-create " *Test Input*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (set-buffer input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (insert-file-contents filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 ;; Run hooks including the uncompression hook.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 ;; 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
187 (let ((buffer-file-name filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (default-major-mode 'emacs-lisp-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (enable-local-eval nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (normal-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (setq filename buffer-file-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (test-harness-from-buffer input-buffer filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (kill-buffer input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
5110
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
196 (defsubst test-harness-backtrace ()
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
197 "Display a reasonable-size backtrace."
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
198 (let ((print-escape-newlines t)
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
199 (print-length 50))
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
200 (backtrace nil t)))
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
201
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
202 (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
203 "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
204 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
205 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
206 `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
207 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
208 is non-nil."
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
209 (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
210 (cond ((and (not noninteractive)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
211 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
212 (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
213 (test-harness-assertion-failure-show-backtrace
5110
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
214 (test-harness-backtrace)))))
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
215
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
216 (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
217 "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
218 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
219 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
220 `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
221 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
222 is non-nil."
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
223 (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
224 (cond ((and (not noninteractive)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
225 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
226 (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
227 (test-harness-unexpected-error-show-backtrace
5110
b24cf478a45e make test backtraces smaller
Ben Wing <ben@xemacs.org>
parents: 5069
diff changeset
228 (test-harness-backtrace)))))
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
229
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
230 (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
231 "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
232 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
233 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
234 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
235 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
236 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
237 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
238 `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
239 `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
240
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
241 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
242 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
243 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
244 wrapping."
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
245 (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
246 (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
247 error-info context-msg))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
248 (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
249 (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
250
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
251 (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
252 "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
253 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
254 `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
255 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
256 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
257 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
258 afterwards. See "
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
259 `(condition-case nil
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
260 (call-with-condition-handler
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
261 #'(lambda (error-info)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
262 (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
263 error-info ,context-msg))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
264 #'(lambda ()
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
265 ,@body))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
266 (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
267
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (defun test-harness-read-from-buffer (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 "Read forms from BUFFER, and turn it into a lambda test form."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (let ((body nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 (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
272 (condition-case nil
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
273 (call-with-condition-handler
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
274 #'(lambda (error-info)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
275 ;; 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
276 ;; 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
277 (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
278 (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
279 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
280 #'(lambda ()
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
281 (while t
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
282 (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
283 (error nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 `(lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (defvar passes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (defvar assertion-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 (defvar no-error-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (defvar wrong-error-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (defvar missing-message-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (defvar other-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (defvar trick-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 ,@(nreverse body))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (defun test-harness-from-buffer (inbuffer filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 "Run tests in buffer INBUFFER, visiting FILENAME."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (defvar trick-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (let ((passes 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (assertion-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (no-error-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (wrong-error-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (missing-message-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (other-failures 0)
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
305 (unexpected-test-file-failures 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
307 ;; #### 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
308 ;; 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
309 ;; 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
310 (skipped-test-reasons (make-hash-table :test 'equal))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
311
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 (trick-optimizer nil)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
313 (debug-on-error t)
5064
501b5e84f5a7 remove unused var in test-harness
Ben Wing <ben@xemacs.org>
parents: 5040
diff changeset
314 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (with-output-to-temp-buffer "*Test-Log*"
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
316 (princ (format "Testing %s...\n\n" filename))
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
317
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
318 (defconst test-harness-failure-tag "FAIL")
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
319 (defconst test-harness-success-tag "PASS")
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
320
4891
732c35cdded8 fix failing-case output of Assert-test, add Assert-test-not
Ben Wing <ben@xemacs.org>
parents: 4856
diff changeset
321 ;;;;; 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
322
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
323 (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
324 "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
325 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
326 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
327 `(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
328 (test-harness-failure-tag "KNOWN BUG")
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
329 (test-harness-success-tag "PASS (FAIL EXPECTED: was bug fixed?)"))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
330 ,@body))
4323
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
331
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
332 (defmacro Known-Bug-Expect-Error (expected-error &rest body)
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
333 "Wrap a BODY containing a test known to trigger an error it shouldn't.
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
334 This causes messages to be printed on failure indicating that this is expected
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
335 of the bug, and on success indicating that this is unexpected."
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
336 `(let ((test-harness-bug-expected t)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
337 (test-harness-failure-tag "KNOWN BUG")
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
338 (test-harness-success-tag
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
339 (format "PASS (EXPECTED ERROR %S due to bug: fixed?)"
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
340 (quote ,expected-error))))
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
341 (condition-case err
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
342 (progn ,@body)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
343 (,expected-error)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
344 (error
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
345 (let ((m (format " Expected %S due to bug, got %S: mutated?\n"
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
346 (quote ,expected-error) err)))
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
347 (if (noninteractive) (message m))
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
348 (princ m))))))
4323
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
349
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
350 (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
351 "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
352 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
353 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
354 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
355 `(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
356 (test-harness-failure-tag "IMPLEMENTATION INCOMPLETE")
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
357 (test-harness-success-tag
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
358 "PASS (FAILURE EXPECTED: feature implemented?)"))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
359 ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
360
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
361 (defun Print-Failure (fmt &rest args)
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
362 (setq fmt (format "%s: %s" test-harness-failure-tag fmt))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
363 (if (noninteractive) (apply #'message fmt args))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
364 (princ (concat (apply #'format fmt args) "\n")))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
365
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
366 (defun Print-Pass (fmt &rest args)
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
367 (setq fmt (format "%s: %s" test-harness-success-tag fmt))
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
368 (and (or test-harness-verbose test-harness-bug-expected)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
369 (if (and noninteractive test-harness-bug-expected)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
370 (apply #'message fmt args))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
371 (princ (concat (apply #'format fmt args) "\n"))))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
372
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
373 (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
374 (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
375 (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
376
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
377 (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
378 "Unless CONDITION is satisfied, skip test BODY.
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
379 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
380 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
381 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
382 `(if (not ,condition)
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
383 (let ((count (gethash ,reason skipped-test-reasons)))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
384 (puthash ,reason (if (null count) 1 (1+ count))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
385 skipped-test-reasons)
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
386 (Print-Skip ,description ,reason))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
387 ,@body))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
391 Optional FAILING-CASE describes the particular failure. Optional
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
392 DESCRIPTION describes the assertion; by default, the unevalated assertion
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
393 expression is given. FAILING-CASE and DESCRIPTION are useful when Assert
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
394 is used in a loop."
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
395 (let ((test-assertion assertion)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
396 (negated nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
397 (when (and (listp test-assertion)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
398 (eql 2 (length test-assertion))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
399 (memq (car test-assertion) '(not null)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
400 (setq test-assertion (cadr test-assertion))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
401 (setq negated t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
402 (when (and (listp test-assertion)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
403 (eql 3 (length test-assertion))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
404 (member (car test-assertion)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
405 '(eq eql equal equalp = string= < <= > >=)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
406 (let* ((test (car test-assertion))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
407 (testval (second test-assertion))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
408 (expected (third test-assertion))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
409 (failmsg `(format ,(if negated
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
410 "%S shouldn't be `%s' to %S but is"
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
411 "%S should be `%s' to %S but isn't")
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
412 ,testval ',test ,expected)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
413 (setq failing-case (if failing-case
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
414 `(concat
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
415 (format "%S, " ,failing-case)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
416 ,failmsg)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5110
diff changeset
417 failmsg)))))
4856
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
418 (let ((description
9bf09492cff7 Clean up macro Assert
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
419 (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
420 `(condition-case nil
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
421 (call-with-condition-handler
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
422 #'(lambda (error-info)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
423 (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
424 (progn
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
425 (Print-Failure
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
426 (if ,failing-case
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
427 "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
428 "Assertion failed: %S")
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
429 ,description ,failing-case)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
430 (incf assertion-failures)
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
431 (test-harness-assertion-failure-do-debug error-info)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
432 nil)
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
433 (Print-Failure
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
434 (if ,failing-case
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
435 "%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
436 "%S ==> error: %S")
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
437 ,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
438 (incf other-failures)
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
439 (test-harness-unexpected-error-do-debug error-info)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
440 nil))
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
441 #'(lambda ()
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
442 (assert ,assertion)
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
443 (Print-Pass "%S" ,description)
5541
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
444 (incf passes)
ebd367b82ccd Improve treatment of expected bugs.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5473
diff changeset
445 t))
5040
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
446 (cl-assertion-failed nil))))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
447
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (defmacro Check-Error (expected-error &rest body)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
449 (let ((quoted-body (if (eql 1 (length body))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 `(quote ,(car body)) `(quote (progn ,@body)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 `(condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (setq trick-optimizer (progn ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
454 (Print-Failure "%S executed successfully, but expected error %S"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 ,quoted-body
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
456 ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (incf no-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (,expected-error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
459 (Print-Pass "%S ==> error %S, as expected"
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
460 ,quoted-body ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (incf passes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
463 (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
464 ,quoted-body ',expected-error error-info)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (incf wrong-error-failures)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
467 (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
468 &rest body)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
469 (let ((quoted-body (if (eql 1 (length body))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 `(quote ,(car body)) `(quote (progn ,@body)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 `(condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (setq trick-optimizer (progn ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
474 (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
475 ,quoted-body ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (incf no-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (,expected-error
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 3472
diff changeset
478 ;; #### Damn, this binding doesn't capture frobs, eg, for
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 3472
diff changeset
479 ;; invalid_argument() ... you only get the REASON. And for
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 3472
diff changeset
480 ;; wrong_type_argument(), there's no reason only FROBs.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 3472
diff changeset
481 ;; If this gets fixed, fix tests in regexp-tests.el.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (let ((error-message (second error-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (if (string-match ,expected-error-regexp error-message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (progn
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
485 (Print-Pass "%S ==> error %S %S, as expected"
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
486 ,quoted-body error-message ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (incf passes))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
488 (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
489 ,quoted-body ',expected-error error-message ,expected-error-regexp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (incf wrong-error-failures))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
492 (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
493 ,quoted-body ',expected-error error-info)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (incf wrong-error-failures)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
496 ;; Do not use this with Silence-Message.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (defmacro Check-Message (expected-message-regexp &rest body)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
498 (let ((quoted-body (if (eql 1 (length body))
5069
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
499 `(quote ,(car body))
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
500 `(quote (progn ,@body)))))
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
501 `(Skip-Test-Unless (fboundp 'defadvice) "can't defadvice"
5274
ecdd1daab447 Add an omitted comma, Check-Message, test-harness.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5136
diff changeset
502 ,expected-message-regexp
5069
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
503 (let ((messages ""))
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
504 (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
505 (defvar messages)
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
506 (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
507 (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
508 msg-string))
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
509 (ignore-errors
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
510 (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
511 #'(lambda (error-info)
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
512 (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
513 ,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
514 (incf other-failures)
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
515 (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
516 #'(lambda ()
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
517 (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
518 (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
519 (progn
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
520 (Print-Pass
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
521 "%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
522 ,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
523 ',expected-message-regexp)
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
524 (incf passes))
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
525 (Print-Failure
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
526 "%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
527 ,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
528 ',expected-message-regexp)
14f0dd1fabdb move test-harness to lisp/ directory so it gets byte-compiled
Ben Wing <ben@xemacs.org>
parents: 5064
diff changeset
529 (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
530 (ad-unadvise 'message)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
532 ;; #### Perhaps this should override `message' itself, too?
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
533 (defmacro Silence-Message (&rest body)
4323
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
534 `(flet ((append-message (&rest args) ())
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
535 (clear-message (&rest args) ()))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
536 ,@body))
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
537
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (defmacro Ignore-Ebola (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 `(let ((debug-issue-ebola-notices -42)) ,@body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 (defun Int-to-Marker (pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (goto-char pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 (point-marker))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 (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
549
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
550 (test-harness-error-wrap
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
551 "executing interpreted code"
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
552 "Test suite execution aborted."
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
553 (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
554
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (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
556
1758
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
557 (let (code
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
558 (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
559 (test-harness-error-wrap
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
560 "byte-compiling code" nil
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
561 (setq code
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
562 ;; 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
563 ;; 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
564 (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
565 'ignore))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
566 (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
567 inbuffer))))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
568 )
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
569
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
570 (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
571 "Test suite execution aborted."
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
572 (if code (funcall code)))
3daf9fc57cd4 fixes to test harness to allow backtracing/debugging of failures
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
573 )
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
574 (princ (format "\nSUMMARY for %s:\n" filename))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 (princ (format "\t%5d passes\n" passes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (princ (format "\t%5d assertion failures\n" assertion-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (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
578 (princ (format "\t%5d wrong-error failures\n" wrong-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 (princ (format "\t%5d missing-message failures\n" missing-message-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 (princ (format "\t%5d other failures\n" other-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 (let* ((total (+ passes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 assertion-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 no-error-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 wrong-error-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 missing-message-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 other-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 (basename (file-name-nondirectory filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (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
589 (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
590 (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
591 (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
592 ((> total 0)
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
593 (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
594 (concat basename ":")
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
595 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
596 (t
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
597 (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
598 (concat basename ":")))))
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
599 (reasons ""))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
600 (maphash (lambda (key value)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
601 (setq reasons
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
602 (concat reasons
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
603 (format "\n %d tests skipped because %s."
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
604 value key))))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
605 skipped-test-reasons)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
606 (when (> (length reasons) 1)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
607 (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
608 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
609 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
610 --package-path to enable the skipped tests.")))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
611 (setq test-harness-file-results-alist
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
612 (cons (list filename passes total)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
613 test-harness-file-results-alist))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (message "%s" summary-msg))
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
615 (when (> unexpected-test-file-failures 0)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
616 (setq unexpected-test-suite-failure-files
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
617 (cons filename unexpected-test-suite-failure-files))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
618 (setq unexpected-test-suite-failures
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
619 (+ unexpected-test-suite-failures unexpected-test-file-failures))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (message "Test suite execution failed unexpectedly."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 (fmakunbound 'Assert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 (fmakunbound 'Check-Error)
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 826
diff changeset
623 (fmakunbound 'Check-Message)
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 826
diff changeset
624 (fmakunbound 'Check-Error-Message)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 (fmakunbound 'Ignore-Ebola)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 (fmakunbound 'Int-to-Marker)
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
627 (and noninteractive
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
628 (message "%s" (buffer-substring-no-properties
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
629 nil nil "*Test-Log*")))
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
630 )))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 (defvar test-harness-results-point-max nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 (defmacro displaying-emacs-test-results (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 `(let ((test-harness-results-point-max test-harness-results-point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 ;; Log the file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 (test-harness-log-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 ;; Record how much is logged now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 ;; We will display the log buffer if anything more is logged
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 ;; before the end of BODY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 (or test-harness-results-point-max
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (set-buffer (get-buffer-create "*Test-Log*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 (setq test-harness-results-point-max (point-max))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 (progn ,@body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 (test-harness-report-error error-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 ;; If there were compilation warnings, display them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 (set-buffer "*Test-Log*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (if (= test-harness-results-point-max (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (if temp-buffer-show-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 (let ((show-buffer (get-buffer-create "*Test-Log-Show*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 (set-buffer show-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (setq buffer-read-only nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (erase-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 (copy-to-buffer show-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (goto-char test-harness-results-point-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (forward-line -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (funcall temp-buffer-show-function show-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 (select-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 (prog1 (selected-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (select-window (display-buffer (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (goto-char test-harness-results-point-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (recenter 1)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (defun batch-test-emacs-1 (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (progn (test-emacs-test-file file) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (princ ">>Error occurred processing ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 (princ file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (princ ": ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 (display-error error-info nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 (defun batch-test-emacs ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 "Run `test-harness' on the files remaining on the command line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 Use this from the command line, with `-batch';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 it won't work in an interactive Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 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
689 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
690 For example, invoke \"xemacs -batch -f batch-test-emacs tests\""
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 ;; 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
692 ;; startup.el)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (defvar command-line-args-left) ;Avoid 'free variable' warning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 (defvar debug-issue-ebola-notices)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (if (not noninteractive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 (error "`batch-test-emacs' is to be used only with -batch"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (let ((error nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (dolist (file command-line-args-left)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (if (file-directory-p file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 (dolist (file-in-dir (directory-files file t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 (when (and (string-match emacs-lisp-file-regexp file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (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
703 (backup-file-name-p file-in-dir))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 (or (batch-test-emacs-1 file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (setq error t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 (or (batch-test-emacs-1 file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 (setq error t))))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
708 (let ((namelen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
709 (succlen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
710 (testlen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
711 (results test-harness-file-results-alist))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
712 ;; compute maximum lengths of variable components of report
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
713 ;; probably should just use (length "byte-compiler-tests.el")
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
714 ;; and 5-place sizes -- this will also work for the file-by-file
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
715 ;; printing when Adrian's kludge gets reverted
5567
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5541
diff changeset
716 (labels ((print-width (i)
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5541
diff changeset
717 (let ((x 10) (y 1))
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5541
diff changeset
718 (while (>= i x)
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5541
diff changeset
719 (setq x (* 10 x) y (1+ y)))
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5541
diff changeset
720 y)))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
721 (while results
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
722 (let* ((head (car results))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
723 (nn (length (file-name-nondirectory (first head))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
724 (ss (print-width (second head)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
725 (tt (print-width (third head))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
726 (when (> nn namelen) (setq namelen nn))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
727 (when (> ss succlen) (setq succlen ss))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
728 (when (> tt testlen) (setq testlen tt)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
729 (setq results (cdr results))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
730 ;; create format and print
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
731 (let ((results (reverse test-harness-file-results-alist)))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
732 (while results
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
733 (let* ((head (car results))
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
734 (basename (file-name-nondirectory (first head)))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
735 (nsucc (second head))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
736 (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
737 (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
738 (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
739 (concat basename ":")
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
740 ntest))
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
741 ((> ntest 0)
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
742 (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
743 (concat basename ":")
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
744 nsucc
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
745 ntest
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
746 (/ (* 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
747 (t
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4891
diff changeset
748 (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
749 (concat basename ":"))))
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
750 (setq results (cdr results)))))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
751 (when (> unexpected-test-suite-failures 0)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
752 (message "\n***** There %s %d unexpected test suite %s in %s:"
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
753 (if (= unexpected-test-suite-failures 1) "was" "were")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
754 unexpected-test-suite-failures
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
755 (if (= unexpected-test-suite-failures 1) "failure" "failures")
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 5274
diff changeset
756 (if (eql (length unexpected-test-suite-failure-files) 1)
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
757 "file"
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
758 "files"))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
759 (while unexpected-test-suite-failure-files
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
760 (let ((line (pop unexpected-test-suite-failure-files)))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
761 (while (and (< (length line) 61)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
762 unexpected-test-suite-failure-files)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
763 (setq line
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
764 (concat line " "
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
765 (pop unexpected-test-suite-failure-files))))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
766 (message line)))))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
767 (message "\nDone")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (kill-emacs (if error 1 0))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (provide 'test-harness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 ;;; test-harness.el ends here