Mercurial > emacs
annotate lisp/eshell/esh-test.el @ 89943:4c90ffeb71c5
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221
Restore deleted tagline in etc/TUTORIAL.ru
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229
Remove TeX output files from the archive
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248
src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264
Update from CVS: lispref/display.texi: emacs -> Emacs.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275
Update from CVS: man/makefile.w32-in: Revert last change
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296
Allow restarting an existing debugger session that's exited
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328
Update from CVS: src/.gdbinit (xsymbol): Fix last change.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345
Tweak source regexps so that building in place won't cause problems
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352
Update from CVS: lisp/flymake.el: New file.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362
Support " [...]" style defaults in minibuffer-electric-default-mode
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363
(read-number): Use canonical format for default in prompt.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368
Improve display-supports-face-attributes-p on non-ttys
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369
Rewrite face-differs-from-default-p
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370
Move `display-supports-face-attributes-p' entirely into C code
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372
Simplify face-differs-from-default-p; don't consider :stipple.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374
(tty_supports_face_attributes_p): Ensure attributes differ from default
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377
(Fdisplay_supports_face_attributes_p): Work around bootstrapping problem
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381
Face merging cleanups
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385
src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396
Tweak arch tagging to make build/install-in-place less annoying
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Work around vc-arch problems when building eshell
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398
Tweak permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399
Tweak directory permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401
More build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403
Yet more build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410
Make sure image types are initialized for lookup too
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 28 Jun 2004 07:56:49 +0000 |
parents | 68c22ea6027c a9bcae5bca8e |
children | 95879cc1ed20 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33020
diff
changeset
|
1 ;;; esh-test.el --- Eshell test suite |
29876 | 2 |
29934
34b1ab9d583d
Change spelling of the Free Software Foundation.
Gerd Moellmann <gerd@gnu.org>
parents:
29876
diff
changeset
|
3 ;; Copyright (C) 1999, 2000 Free Software Foundation |
29876 | 4 |
32526 | 5 ;; Author: John Wiegley <johnw@gnu.org> |
6 | |
29876 | 7 ;; This file is part of GNU Emacs. |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 (provide 'esh-test) | |
25 | |
26 (eval-when-compile (require 'esh-maint)) | |
27 | |
28 (defgroup eshell-test nil | |
29 "This module is meant to ensure that Eshell is working correctly." | |
30 :tag "Eshell test suite" | |
31 :group 'eshell) | |
32 | |
33 ;;; Commentary: | |
34 | |
35 ;; The purpose of this module is to verify that Eshell works as | |
36 ;; expected. To run it on your system, use the command | |
37 ;; \\[eshell-test]. | |
38 | |
39 ;;; Code: | |
40 | |
41 (require 'esh-mode) | |
42 | |
43 ;;; User Variables: | |
44 | |
45 (defface eshell-test-ok-face | |
46 '((((class color) (background light)) (:foreground "Green" :bold t)) | |
47 (((class color) (background dark)) (:foreground "Green" :bold t))) | |
48 "*The face used to highlight OK result strings." | |
49 :group 'eshell-test) | |
50 | |
51 (defface eshell-test-failed-face | |
52 '((((class color) (background light)) (:foreground "OrangeRed" :bold t)) | |
53 (((class color) (background dark)) (:foreground "OrangeRed" :bold t)) | |
54 (t (:bold t))) | |
55 "*The face used to highlight FAILED result strings." | |
56 :group 'eshell-test) | |
57 | |
58 (defcustom eshell-show-usage-metrics nil | |
59 "*If non-nil, display different usage metrics for each Eshell command." | |
60 :set (lambda (symbol value) | |
61 (if value | |
62 (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics) | |
63 (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics)) | |
64 (set symbol value)) | |
65 :type '(choice (const :tag "No metrics" nil) | |
66 (const :tag "Cons cells consumed" t) | |
67 (const :tag "Time elapsed" 0)) | |
68 :group 'eshell-test) | |
69 | |
70 ;;; Code: | |
71 | |
72 (eval-when-compile | |
73 (defvar test-buffer)) | |
74 | |
75 (defun eshell-insert-command (text &optional func) | |
76 "Insert a command at the end of the buffer." | |
77 (goto-char eshell-last-output-end) | |
78 (insert-and-inherit text) | |
79 (funcall (or func 'eshell-send-input))) | |
80 | |
81 (defun eshell-match-result (regexp) | |
82 "Insert a command at the end of the buffer." | |
83 (goto-char eshell-last-input-end) | |
84 (looking-at regexp)) | |
85 | |
86 (defun eshell-command-result-p (text regexp &optional func) | |
87 "Insert a command at the end of the buffer." | |
88 (eshell-insert-command text func) | |
89 (eshell-match-result regexp)) | |
90 | |
91 (defvar eshell-test-failures nil) | |
92 | |
93 (defun eshell-run-test (module funcsym label command) | |
94 "Test whether FORM evaluates to a non-nil value." | |
95 (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module))))) | |
96 (or (memq sym (eshell-subgroups 'eshell)) | |
97 (eshell-using-module sym))) | |
98 (with-current-buffer test-buffer | |
99 (insert-before-markers | |
100 (format "%-70s " (substring label 0 (min 70 (length label))))) | |
101 (insert-before-markers " ....") | |
102 (eshell-redisplay)) | |
103 (let ((truth (eval command))) | |
104 (with-current-buffer test-buffer | |
105 (delete-backward-char 6) | |
106 (insert-before-markers | |
107 "[" (let (str) | |
108 (if truth | |
109 (progn | |
110 (setq str " OK ") | |
111 (put-text-property 0 6 'face | |
112 'eshell-test-ok-face str)) | |
113 (setq str "FAILED") | |
114 (setq eshell-test-failures (1+ eshell-test-failures)) | |
115 (put-text-property 0 6 'face | |
116 'eshell-test-failed-face str)) | |
117 str) "]") | |
118 (add-text-properties (line-beginning-position) (point) | |
119 (list 'test-func funcsym)) | |
120 (eshell-redisplay))))) | |
121 | |
122 (defun eshell-test-goto-func () | |
123 "Jump to the function that defines a particular test." | |
124 (interactive) | |
125 (let ((fsym (get-text-property (point) 'test-func))) | |
126 (when fsym | |
127 (let* ((def (symbol-function fsym)) | |
128 (library (locate-library (symbol-file fsym))) | |
129 (name (substring (symbol-name fsym) | |
130 (length "eshell-test--"))) | |
131 (inhibit-redisplay t)) | |
132 (find-file library) | |
133 (goto-char (point-min)) | |
134 (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+" | |
135 name)) | |
136 (beginning-of-line))))) | |
137 | |
138 (defun eshell-run-one-test (&optional arg) | |
139 "Jump to the function that defines a particular test." | |
140 (interactive "P") | |
141 (let ((fsym (get-text-property (point) 'test-func))) | |
142 (when fsym | |
143 (beginning-of-line) | |
144 (delete-region (point) (line-end-position)) | |
145 (let ((test-buffer (current-buffer))) | |
146 (set-buffer (let ((inhibit-redisplay t)) | |
147 (save-window-excursion (eshell t)))) | |
148 (funcall fsym) | |
149 (unless arg | |
150 (kill-buffer (current-buffer))))))) | |
151 | |
152 ;;;###autoload | |
153 (defun eshell-test (&optional arg) | |
154 "Test Eshell to verify that it works as expected." | |
155 (interactive "P") | |
156 (let* ((begin (eshell-time-to-seconds (current-time))) | |
157 (test-buffer (get-buffer-create "*eshell test*"))) | |
158 (set-buffer (let ((inhibit-redisplay t)) | |
159 (save-window-excursion (eshell t)))) | |
160 (with-current-buffer test-buffer | |
161 (erase-buffer) | |
162 (setq major-mode 'eshell-test-mode) | |
163 (setq mode-name "EShell Test") | |
164 (set (make-local-variable 'eshell-test-failures) 0) | |
165 (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func) | |
166 (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test) | |
167 (local-set-key [(control ?m)] 'eshell-test-goto-func) | |
168 (local-set-key [return] 'eshell-test-goto-func) | |
169 | |
55581
a9bcae5bca8e
2004-05-13 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
170 (insert "Testing Eshell under " (emacs-version)) |
29876 | 171 (switch-to-buffer test-buffer) |
172 (delete-other-windows)) | |
33020 | 173 (eshell-for funcname (sort (all-completions "eshell-test--" |
174 obarray 'functionp) | |
175 'string-lessp) | |
29876 | 176 (with-current-buffer test-buffer |
177 (insert "\n")) | |
178 (funcall (intern-soft funcname))) | |
179 (with-current-buffer test-buffer | |
180 (insert (format "\n\n--- %s --- (completed in %d seconds)\n" | |
181 (current-time-string) | |
182 (- (eshell-time-to-seconds (current-time)) | |
183 begin))) | |
184 (message "Eshell test suite completed: %s failure%s" | |
185 (if (> eshell-test-failures 0) | |
186 (number-to-string eshell-test-failures) | |
187 "No") | |
188 (if (= eshell-test-failures 1) "" "s")))) | |
189 (goto-char eshell-last-output-end) | |
190 (unless arg | |
191 (kill-buffer (current-buffer)))) | |
192 | |
193 | |
194 (defvar eshell-metric-before-command 0) | |
195 (defvar eshell-metric-after-command 0) | |
196 | |
197 (defun eshell-show-usage-metrics () | |
198 "If run at Eshell mode startup, metrics are shown after each command." | |
199 (set (make-local-variable 'eshell-metric-before-command) | |
200 (if (eq eshell-show-usage-metrics t) | |
201 0 | |
202 (current-time))) | |
203 (set (make-local-variable 'eshell-metric-after-command) | |
204 (if (eq eshell-show-usage-metrics t) | |
205 0 | |
206 (current-time))) | |
207 | |
208 (add-hook 'eshell-pre-command-hook | |
209 (function | |
210 (lambda () | |
211 (setq eshell-metric-before-command | |
212 (if (eq eshell-show-usage-metrics t) | |
213 (car (memory-use-counts)) | |
214 (current-time))))) nil t) | |
215 | |
216 (add-hook 'eshell-post-command-hook | |
217 (function | |
218 (lambda () | |
219 (setq eshell-metric-after-command | |
220 (if (eq eshell-show-usage-metrics t) | |
221 (car (memory-use-counts)) | |
222 (current-time))) | |
223 (eshell-interactive-print | |
224 (concat | |
225 (int-to-string | |
226 (if (eq eshell-show-usage-metrics t) | |
227 (- eshell-metric-after-command | |
228 eshell-metric-before-command 7) | |
229 (- (eshell-time-to-seconds | |
230 eshell-metric-after-command) | |
231 (eshell-time-to-seconds | |
232 eshell-metric-before-command)))) | |
233 "\n")))) | |
234 nil t)) | |
235 | |
52401 | 236 ;;; arch-tag: 6e32275a-8285-4a4e-b7cf-819aa7c86b8e |
29876 | 237 ;;; esh-test.el ends here |