annotate tests/automated/test-harness.el @ 4633:199ecf2503c8

Add standard section headers in preparation for 21.5.29.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 18 Apr 2009 03:18:27 +0900
parents bceb3e285ae7
children 294a86d29f99
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.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
4 ;;; Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Author: Martin Buchholz
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; General Public License for more details.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
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 ;;; Synched up with: Not in FSF.
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 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;; A test suite harness for testing XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; The actual tests are in other files in this directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;;; 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
34 ;;; 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
35 ;;; 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
36 ;;; 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
37 ;;; fixed -- use the Known-Bug-Expect-Failure and
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
38 ;;; 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
39 ;;; 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
40 ;;; Ignore-Ebola wrapper macro.
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
41 ;;; 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
42 ;;; 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
43 ;;; 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
44 ;;; `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
45 ;;; 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
46 ;;; 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
47 ;;; 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
48 ;;; test, not on tests.
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
49 ;;;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;;; You run the tests using M-x test-emacs-test-file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 ;;; or $(EMACS) -batch -l .../test-harness.el -f batch-test-emacs file ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 ;;; 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
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (require 'bytecomp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
56 (defvar unexpected-test-suite-failures 0
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
57 "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
58
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
59 \"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
60 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
61 suite for the file being tested.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
62
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
63 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
64 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
65 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
66
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
67 (defvar unexpected-test-suite-failure-files nil
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
68 "List of test files causing unexpected failures.")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
69
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
70 ;; Declared for dynamic scope; _do not_ initialize here.
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
71 (defvar unexpected-test-file-failures)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
72
1758
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
73 (defvar test-harness-test-compiled nil
4366
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
74 "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
75
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
76 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
77 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
78 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
79 implementation of this variable:
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
80
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
81 \(when test-harness-test-compiled
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
82 ;; 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
83 \(setq test-harness-failure-tag
7b628daa39d4 Move debugging code to usage example.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4323
diff changeset
84 \"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
85
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (defvar test-harness-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (and (not noninteractive) (> (device-baud-rate) search-slow-speed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 "*Non-nil means print messages describing progress of emacs-tester.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
90 (defvar test-harness-file-results-alist nil
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
91 "Each element is a list (FILE SUCCESSES TESTS).
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
92 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
93
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
94 FILE is a string naming the test file.
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
95 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
96 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
97
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
98 (defvar test-harness-risk-infloops nil
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
99 "*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
100
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (defvar test-harness-current-file nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (defvar emacs-lisp-file-regexp (purecopy "\\.el\\'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 "*Regexp which matches Emacs Lisp source files.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
106 (defconst test-harness-file-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
107 (format "%%-%ds %%%dd of %%%dd tests successful (%%3d%%%%)."
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
108 (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
109 5
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
110 5)
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
111 "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
112
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
113 (defconst test-harness-null-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
114 (format "%%-%ds No tests run."
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
115 (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
116 "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
117
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (defun test-emacs-test-file (filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 "Test a file of Lisp code named FILENAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 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
122 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (let ((file buffer-file-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (file-name nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (file-dir nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (and file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (eq (cdr (assq 'major-mode (buffer-local-variables)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 'emacs-lisp-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (setq file-name (file-name-nondirectory file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 file-dir (file-name-directory file)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (list (read-file-name "Test file: " file-dir nil nil file-name))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 ;; Expand now so we get the current buffer's defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (setq filename (expand-file-name filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 ;; 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
136 ;; to save it first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (or noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 (let ((b (get-file-buffer (expand-file-name filename))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (if (and b (buffer-modified-p b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (y-or-n-p (format "save buffer %s first? " (buffer-name b))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (save-excursion (set-buffer b) (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (if (or noninteractive test-harness-verbose)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (message "Testing %s..." filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (let ((test-harness-current-file filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (setq input-buffer (get-buffer-create " *Test Input*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (set-buffer input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (insert-file-contents filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 ;; Run hooks including the uncompression hook.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 ;; 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
154 (let ((buffer-file-name filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (default-major-mode 'emacs-lisp-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (enable-local-eval nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (normal-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (setq filename buffer-file-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (test-harness-from-buffer input-buffer filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (kill-buffer input-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (defun test-harness-read-from-buffer (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 "Read forms from BUFFER, and turn it into a lambda test form."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (let ((body nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (goto-char (point-min) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (while t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (setq body (cons (read buffer) body)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (end-of-file nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (error
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
172 (incf unexpected-test-file-failures)
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
173 (princ (format "Unexpected error %S reading forms from buffer\n"
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
174 error-info))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 `(lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (defvar passes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (defvar assertion-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (defvar no-error-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (defvar wrong-error-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (defvar missing-message-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (defvar other-failures)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (defvar trick-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 ,@(nreverse body))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (defun test-harness-from-buffer (inbuffer filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 "Run tests in buffer INBUFFER, visiting FILENAME."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (defvar trick-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (let ((passes 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (assertion-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (no-error-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (wrong-error-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (missing-message-failures 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (other-failures 0)
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
196 (unexpected-test-file-failures 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
198 ;; #### 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
199 ;; 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
200 ;; 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
201 (skipped-test-reasons (make-hash-table :test 'equal))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (trick-optimizer nil)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
204 (debug-on-error t)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
205 (pass-stream nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (with-output-to-temp-buffer "*Test-Log*"
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
207 (princ (format "Testing %s...\n\n" filename))
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
208
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
209 (defconst test-harness-failure-tag "FAIL")
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
210 (defconst test-harness-success-tag "PASS")
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
211
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
212 (defmacro Known-Bug-Expect-Failure (&rest body)
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
213 `(let ((test-harness-failure-tag "KNOWN BUG")
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
214 (test-harness-success-tag "PASS (FAILURE EXPECTED)"))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
215 ,@body))
4323
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
216
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
217 (defmacro Known-Bug-Expect-Error (expected-error &rest body)
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
218 (let ((quoted-body (if (= 1 (length body))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
219 `(quote ,(car body)) `(quote (progn ,@body)))))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
220 `(let ((test-harness-failure-tag "KNOWN BUG")
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
221 (test-harness-success-tag "PASS (FAILURE EXPECTED)"))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
222 (condition-case error-info
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
223 (progn
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
224 (setq trick-optimizer (progn ,@body))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
225 (Print-Pass
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
226 "%S executed successfully, but expected error %S"
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
227 ,quoted-body
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
228 ',expected-error)
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
229 (incf passes))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
230 (,expected-error
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
231 (Print-Failure "%S ==> error %S, as expected"
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
232 ,quoted-body ',expected-error)
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
233 (incf no-error-failures))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
234 (error
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
235 (Print-Failure "%S ==> expected error %S, got error %S instead"
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
236 ,quoted-body ',expected-error error-info)
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
237 (incf wrong-error-failures))))))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
238
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
239 (defmacro Implementation-Incomplete-Expect-Failure (&rest body)
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
240 `(let ((test-harness-failure-tag "IMPLEMENTATION INCOMPLETE")
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
241 (test-harness-success-tag "PASS (FAILURE EXPECTED)"))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
242 ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
243
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
244 (defun Print-Failure (fmt &rest args)
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
245 (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
246 (if (noninteractive) (apply #'message fmt args))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
247 (princ (concat (apply #'format fmt args) "\n")))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
248
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
249 (defun Print-Pass (fmt &rest args)
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1231
diff changeset
250 (setq fmt (format "%s: %s" test-harness-success-tag fmt))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
251 (and test-harness-verbose
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
252 (princ (concat (apply #'format fmt args) "\n"))))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
253
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
254 (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
255 (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
256 (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
257
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
258 (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
259 "Unless CONDITION is satisfied, skip test BODY.
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
260 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
261 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
262 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
263 `(if (not ,condition)
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
264 (let ((count (gethash ,reason skipped-test-reasons)))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
265 (puthash ,reason (if (null count) 1 (1+ count))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
266 skipped-test-reasons)
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
267 (Print-Skip ,description ,reason))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
268 ,@body))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
270 (defmacro Assert (assertion &optional failing-case)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 `(condition-case error-info
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
272 (progn
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
273 (assert ,assertion)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
274 (Print-Pass "%S" (quote ,assertion))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
275 (incf passes))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
276 (cl-assertion-failed
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
277 (Print-Failure (if ,failing-case
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
278 "Assertion failed: %S; failing case = %S"
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
279 "Assertion failed: %S")
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
280 (quote ,assertion) ,failing-case)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
281 (incf assertion-failures))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
282 (t (Print-Failure (if ,failing-case
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
283 "%S ==> error: %S; failing case = %S"
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
284 "%S ==> error: %S")
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
285 (quote ,assertion) error-info ,failing-case)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
286 (incf other-failures)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
287 )))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1761
diff changeset
288
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (defmacro Check-Error (expected-error &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (let ((quoted-body (if (= 1 (length body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 `(quote ,(car body)) `(quote (progn ,@body)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 `(condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (setq trick-optimizer (progn ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
296 (Print-Failure "%S executed successfully, but expected error %S"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 ,quoted-body
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
298 ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (incf no-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (,expected-error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
301 (Print-Pass "%S ==> error %S, as expected"
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
302 ,quoted-body ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (incf passes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
305 (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
306 ,quoted-body ',expected-error error-info)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (incf wrong-error-failures)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
309 (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
310 &rest body)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (let ((quoted-body (if (= 1 (length body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 `(quote ,(car body)) `(quote (progn ,@body)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 `(condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (setq trick-optimizer (progn ,@body))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
316 (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
317 ,quoted-body ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (incf no-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (,expected-error
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 3472
diff changeset
320 ;; #### 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
321 ;; 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
322 ;; 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
323 ;; If this gets fixed, fix tests in regexp-tests.el.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (let ((error-message (second error-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (if (string-match ,expected-error-regexp error-message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (progn
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
327 (Print-Pass "%S ==> error %S %S, as expected"
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
328 ,quoted-body error-message ',expected-error)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (incf passes))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
330 (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
331 ,quoted-body ',expected-error error-message ,expected-error-regexp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (incf wrong-error-failures))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (error
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
334 (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
335 ,quoted-body ',expected-error error-info)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (incf wrong-error-failures)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
338 ;; Do not use this with Silence-Message.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (defmacro Check-Message (expected-message-regexp &rest body)
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
340 (Skip-Test-Unless (fboundp 'defadvice)
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
341 "can't defadvice"
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
342 expected-message-regexp
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
343 (let ((quoted-body (if (= 1 (length body))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
344 `(quote ,(car body))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
345 `(quote (progn ,@body)))))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
346 `(let ((messages ""))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
347 (defadvice message (around collect activate)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
348 (defvar messages)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
349 (let ((msg-string (apply 'format (ad-get-args 0))))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
350 (setq messages (concat messages msg-string))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
351 msg-string))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
352 (condition-case error-info
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
353 (progn
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
354 (setq trick-optimizer (progn ,@body))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
355 (if (string-match ,expected-message-regexp messages)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
356 (progn
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
357 (Print-Pass "%S ==> value %S, message %S, matching %S, as expected"
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
358 ,quoted-body trick-optimizer messages ',expected-message-regexp)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
359 (incf passes))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
360 (Print-Failure "%S ==> value %S, message %S, NOT matching expected %S"
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
361 ,quoted-body trick-optimizer messages
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
362 ',expected-message-regexp)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
363 (incf missing-message-failures)))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
364 (error
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
365 (Print-Failure "%S ==> unexpected error %S"
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
366 ,quoted-body error-info)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
367 (incf other-failures)))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
368 (ad-unadvise 'message)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
370 ;; #### Perhaps this should override `message' itself, too?
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
371 (defmacro Silence-Message (&rest body)
4323
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
372 `(flet ((append-message (&rest args) ())
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
373 (clear-message (&rest args) ()))
94509abd0ef0 Commit a forgotten chunk of 4d0f773d5e21.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
374 ,@body))
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3471
diff changeset
375
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (defmacro Ignore-Ebola (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 `(let ((debug-issue-ebola-notices -42)) ,@body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (defun Int-to-Marker (pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 (goto-char pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 (point-marker))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 (princ "Testing Interpreted Lisp\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 (funcall (test-harness-read-from-buffer inbuffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 (error
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
390 (incf unexpected-test-file-failures)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (princ (format "Unexpected error %S while executing interpreted code\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 error-info))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (message "Unexpected error %S while executing interpreted code." error-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (message "Test suite execution aborted." error-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (princ "\nTesting Compiled Lisp\n\n")
1758
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
397 (let (code
90502933fb98 [xemacs-hg @ 2003-10-21 08:21:00 by stephent]
stephent
parents: 1751
diff changeset
398 (test-harness-test-compiled t))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (condition-case error-info
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 428
diff changeset
400 (setq code
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 428
diff changeset
401 ;; our lisp code is often intentionally dubious,
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 428
diff changeset
402 ;; so throw away _all_ the byte compiler warnings.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 428
diff changeset
403 (letf (((symbol-function 'byte-compile-warn) 'ignore))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 428
diff changeset
404 (byte-compile (test-harness-read-from-buffer inbuffer))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 (princ (format "Unexpected error %S while byte-compiling code\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 error-info))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (if code (funcall code))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 (error
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
411 (incf unexpected-test-file-failures)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (princ (format "Unexpected error %S while executing byte-compiled code\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 error-info))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (message "Unexpected error %S while executing byte-compiled code." error-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (message "Test suite execution aborted." error-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 )))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 446
diff changeset
417 (princ (format "\nSUMMARY for %s:\n" filename))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (princ (format "\t%5d passes\n" passes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (princ (format "\t%5d assertion failures\n" assertion-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (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
421 (princ (format "\t%5d wrong-error failures\n" wrong-error-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (princ (format "\t%5d missing-message failures\n" missing-message-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (princ (format "\t%5d other failures\n" other-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (let* ((total (+ passes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 assertion-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 no-error-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 wrong-error-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 missing-message-failures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 other-failures))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (basename (file-name-nondirectory filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (summary-msg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (if (> total 0)
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
433 (format test-harness-file-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
434 (concat basename ":")
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
435 passes total (/ (* 100 passes) total))
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
436 (format test-harness-null-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
437 (concat basename ":"))))
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
438 (reasons ""))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
439 (maphash (lambda (key value)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
440 (setq reasons
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
441 (concat reasons
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 973
diff changeset
442 (format "\n %d tests skipped because %s."
973
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
443 value key))))
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
444 skipped-test-reasons)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
445 (when (> (length reasons) 1)
ea6a06f7bf2c [xemacs-hg @ 2002-08-22 14:56:23 by stephent]
stephent
parents: 928
diff changeset
446 (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
447 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
448 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
449 --package-path to enable the skipped tests.")))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
450 (setq test-harness-file-results-alist
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
451 (cons (list filename passes total)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
452 test-harness-file-results-alist))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (message "%s" summary-msg))
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
454 (when (> unexpected-test-file-failures 0)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
455 (setq unexpected-test-suite-failure-files
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
456 (cons filename unexpected-test-suite-failure-files))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
457 (setq unexpected-test-suite-failures
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
458 (+ unexpected-test-suite-failures unexpected-test-file-failures))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (message "Test suite execution failed unexpectedly."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (fmakunbound 'Assert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (fmakunbound 'Check-Error)
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 826
diff changeset
462 (fmakunbound 'Check-Message)
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 826
diff changeset
463 (fmakunbound 'Check-Error-Message)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (fmakunbound 'Ignore-Ebola)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (fmakunbound 'Int-to-Marker)
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
466 (and noninteractive
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
467 (message "%s" (buffer-substring-no-properties
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
468 nil nil "*Test-Log*")))
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
469 )))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (defvar test-harness-results-point-max nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (defmacro displaying-emacs-test-results (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 `(let ((test-harness-results-point-max test-harness-results-point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 ;; Log the file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (test-harness-log-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 ;; Record how much is logged now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 ;; We will display the log buffer if anything more is logged
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 ;; before the end of BODY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (or test-harness-results-point-max
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (set-buffer (get-buffer-create "*Test-Log*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (setq test-harness-results-point-max (point-max))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (progn ,@body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (test-harness-report-error error-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ;; If there were compilation warnings, display them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (set-buffer "*Test-Log*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (if (= test-harness-results-point-max (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (if temp-buffer-show-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (let ((show-buffer (get-buffer-create "*Test-Log-Show*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (set-buffer show-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (setq buffer-read-only nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (erase-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (copy-to-buffer show-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (goto-char test-harness-results-point-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (forward-line -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (funcall temp-buffer-show-function show-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (select-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (prog1 (selected-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (select-window (display-buffer (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (goto-char test-harness-results-point-max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (recenter 1)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (defun batch-test-emacs-1 (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (condition-case error-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 (progn (test-emacs-test-file file) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (princ ">>Error occurred processing ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (princ file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (princ ": ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 (display-error error-info nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (defun batch-test-emacs ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 "Run `test-harness' on the files remaining on the command line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 Use this from the command line, with `-batch';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 it won't work in an interactive Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 Each file is processed even if an error occurred previously.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 For example, invoke \"xemacs -batch -f batch-test-emacs tests/*.el\""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 ;; 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
530 ;; startup.el)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 (defvar command-line-args-left) ;Avoid 'free variable' warning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 (defvar debug-issue-ebola-notices)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (if (not noninteractive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (error "`batch-test-emacs' is to be used only with -batch"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 (let ((error nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 (dolist (file command-line-args-left)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (if (file-directory-p file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (dolist (file-in-dir (directory-files file t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (when (and (string-match emacs-lisp-file-regexp file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (not (or (auto-save-file-name-p file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 (backup-file-name-p file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (equal (file-name-nondirectory file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 "test-harness.el"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 (or (batch-test-emacs-1 file-in-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (setq error t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 (or (batch-test-emacs-1 file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 (setq error t))))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
548 (let ((namelen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
549 (succlen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
550 (testlen 0)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
551 (results test-harness-file-results-alist))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
552 ;; compute maximum lengths of variable components of report
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
553 ;; 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
554 ;; 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
555 ;; printing when Adrian's kludge gets reverted
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
556 (flet ((print-width (i)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
557 (let ((x 10) (y 1))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
558 (while (>= i x)
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
559 (setq x (* 10 x) y (1+ y)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
560 y)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
561 (while results
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
562 (let* ((head (car results))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
563 (nn (length (file-name-nondirectory (first head))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
564 (ss (print-width (second head)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
565 (tt (print-width (third head))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
566 (when (> nn namelen) (setq namelen nn))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
567 (when (> ss succlen) (setq succlen ss))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
568 (when (> tt testlen) (setq testlen tt)))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
569 (setq results (cdr results))))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
570 ;; create format and print
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
571 (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
572 (while results
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
573 (let* ((head (car results))
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
574 (basename (file-name-nondirectory (first head)))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
575 (nsucc (second head))
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
576 (ntest (third head)))
1722
c04bc2b126ef [xemacs-hg @ 2003-09-28 18:54:27 by adrian]
adrian
parents: 1720
diff changeset
577 (if (> ntest 0)
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
578 (message test-harness-file-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
579 (concat basename ":")
1722
c04bc2b126ef [xemacs-hg @ 2003-09-28 18:54:27 by adrian]
adrian
parents: 1720
diff changeset
580 nsucc
c04bc2b126ef [xemacs-hg @ 2003-09-28 18:54:27 by adrian]
adrian
parents: 1720
diff changeset
581 ntest
c04bc2b126ef [xemacs-hg @ 2003-09-28 18:54:27 by adrian]
adrian
parents: 1720
diff changeset
582 (/ (* 100 nsucc) ntest))
1751
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
583 (message test-harness-null-summary-template
5a9a66ba67ca [xemacs-hg @ 2003-10-15 08:56:35 by stephent]
stephent
parents: 1722
diff changeset
584 (concat basename ":")))
3471
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
585 (setq results (cdr results)))))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
586 (when (> unexpected-test-suite-failures 0)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
587 (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
588 (if (= unexpected-test-suite-failures 1) "was" "were")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
589 unexpected-test-suite-failures
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
590 (if (= unexpected-test-suite-failures 1) "failure" "failures")
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
591 (if (= (length unexpected-test-suite-failure-files) 1)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
592 "file"
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
593 "files"))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
594 (while unexpected-test-suite-failure-files
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
595 (let ((line (pop unexpected-test-suite-failure-files)))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
596 (while (and (< (length line) 61)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
597 unexpected-test-suite-failure-files)
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
598 (setq line
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
599 (concat line " "
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
600 (pop unexpected-test-suite-failure-files))))
3b1f8220a65e [xemacs-hg @ 2006-06-24 13:50:19 by stephent]
stephent
parents: 2056
diff changeset
601 (message line)))))
1719
d9c4b6e360d8 [xemacs-hg @ 2003-09-27 06:51:16 by stephent]
stephent
parents: 1717
diff changeset
602 (message "\nDone")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 (kill-emacs (if error 1 0))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 (provide 'test-harness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 ;;; test-harness.el ends here