annotate test/cedet/cedet-utests.el @ 106276:78a8cf7b5387

* sha1.el (sha1-string-external): default-directory "/" in case otherwise non-existent. process-connection-type pipe for touch of efficiency recommended by elisp manual. (An aside in Bug#3911.)
author Kevin Ryde <user42@zip.com.au>
date Thu, 26 Nov 2009 23:38:18 +0000
parents 7f4c7f5c0eba
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; cedet-utests.el --- Run all unit tests in the CEDET suite.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Remembering to run all the unit tests available in CEDET one at a
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; time is a bit time consuming. This links all the tests together
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; into one command.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 (require 'cedet)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;; Code:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 (defvar cedet-utest-test-alist
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 '(
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; COMMON
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; Test inversion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ("inversion" . inversion-unit-test)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; EZ Image dumping.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ("ezimage associations" . ezimage-image-association-dump)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ("ezimage images" . ezimage-image-dump)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; Pulse
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ("pulse interactive test" . (lambda () (pulse-test t)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; Files
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ("cedet file conversion" . cedet-files-utest)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; EIEIO
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ("eieio" . (lambda () (let ((lib (locate-library "eieio-tests.el"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 t)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (load-file lib))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ("eieio: browser" . eieio-browse)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ("eieio: custom" . (lambda ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (require 'eieio-custom)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (customize-variable 'eieio-widget-test)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ("eieio: chart" . (lambda ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (message " ** Skipping test in noninteractive mode.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (chart-test-it-all))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; EDE
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 ;; @todo - Currently handled in the integration tests. Need
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ;; some simpler unit tests here.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;; SEMANTIC
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ("semantic: lex spp table write" . semantic-lex-spp-write-utest)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ("semantic: multi-lang parsing" . semantic-utest-main)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 ("semantic: C preprocessor" . semantic-utest-c)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 ("semantic: analyzer tests" . semantic-ia-utest)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 ("semanticdb: data cache" . semantic-test-data-cache)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 ("semantic: throw-on-input" .
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (lambda ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (message " ** Skipping test in noninteractive mode.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (semantic-test-throw-on-input))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ("semantic: gcc: output parse test" . semantic-gcc-test-output-parser)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;; SRECODE
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 ("srecode: fields" . srecode-field-utest)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ("srecode: templates" . srecode-utest-template-output)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ("srecode: show maps" . srecode-get-maps)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ("srecode: getset" . srecode-utest-getset-output)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 "Alist of all the tests in CEDET we should run.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 (defvar cedet-running-master-tests nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 "Non-nil when CEDET-utest is running all the tests.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (defun cedet-utest (&optional exit-on-error)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 "Run the CEDET unittests.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 EXIT-ON-ERROR causes the test suite to exit on an error, instead
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 of just logging the error."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (if (or (not (featurep 'semanticdb-mode))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (not (semanticdb-minor-mode-p)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (error "CEDET Tests require: M-x semantic-load-enable-minimum-features"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (cedet-utest-log-setup "ALL TESTS")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (let ((tl cedet-utest-test-alist)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (notes nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (err nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (start (current-time))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (end nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (cedet-running-master-tests t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (dolist (T tl)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (cedet-utest-add-log-item-start (car T))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (setq notes nil err nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (condition-case Cerr
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (progn
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (funcall (cdr T))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (error
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (setq err (format "ERROR: %S" Cerr))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ;;(message "Error caught: %s" Cerr)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 ;; Cleanup stray input and events that are in the way.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 ;; Not doing this causes sit-for to not refresh the screen.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 ;; Doing this causes the user to need to press keys more frequently.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (when (and (interactive-p) (input-pending-p))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (if (fboundp 'read-event)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (read-event)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (read-char)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (cedet-utest-add-log-item-done notes err)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (when (and exit-on-error err)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (message "to debug this test point, execute:")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (message "%S" (cdr T))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (message "\n ** Exiting Test Suite. ** \n")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (throw 'cedet-utest-exit-on-error t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (setq end (current-time))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (cedet-utest-log-shutdown-msg "ALL TESTS" start end)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 nil))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (defun cedet-utest-noninteractive ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 "Return non-nil if running non-interactively."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (if (featurep 'xemacs)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 noninteractive))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 ;;;###autoload
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (defun cedet-utest-batch ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 "Run the CEDET unit test in BATCH mode."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (unless (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (error "`cedet-utest-batch' is to be used only with -batch"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (condition-case err
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (when (catch 'cedet-utest-exit-on-error
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 ;; Get basic semantic features up.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (semantic-load-enable-minimum-features)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 ;; Disables all caches related to semantic DB so all
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 ;; tests run as if we have bootstrapped CEDET for the
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 ;; first time.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (setq-default semanticdb-new-database-class 'semanticdb-project-database)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (message "Disabling existing Semantic Database Caches.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 ;; Disabling the srecoder map, we won't load a pre-existing one
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 ;; and will be forced to bootstrap a new one.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (setq srecode-map-save-file nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 ;; Run the tests
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (cedet-utest t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (kill-emacs 1))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (error
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (error "Error in unit test harness:\n %S" err))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ;;; Logging utility.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (defvar cedet-utest-frame nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 "Frame used during cedet unit test logging.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (defvar cedet-utest-buffer nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 "Frame used during cedet unit test logging.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (defvar cedet-utest-frame-parameters
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 '((name . "CEDET-UTEST")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (width . 80)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (height . 25)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (minibuffer . t))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 "Frame parameters used for the cedet utest log frame.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (defvar cedet-utest-last-log-item nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 "Remember the last item we were logging for.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 (defvar cedet-utest-log-timer nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 "During a test, track the start time.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (defun cedet-utest-log-setup (&optional title)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 "Setup a frame and buffer for unit testing.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 Optional argument TITLE is the title of this testing session."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq cedet-utest-log-timer (current-time))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (message "\n>> Setting up %s tests to run @ %s\n"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (or title "")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (current-time-string))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; Interactive mode needs a frame and buffer.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (when (or (not cedet-utest-frame) (not (frame-live-p cedet-utest-frame)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (setq cedet-utest-frame (make-frame cedet-utest-frame-parameters)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (when (or (not cedet-utest-buffer) (not (buffer-live-p cedet-utest-buffer)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (setq cedet-utest-buffer (get-buffer-create "*CEDET utest log*")))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (setq cedet-utest-last-log-item nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (when (not cedet-running-master-tests)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (erase-buffer))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (insert "\n\nSetting up "
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (or title "")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 " tests to run @ " (current-time-string) "\n\n"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (let ((oframe (selected-frame)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (unwind-protect
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (progn
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (select-frame cedet-utest-frame)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (switch-to-buffer cedet-utest-buffer t))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (select-frame oframe)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (defun cedet-utest-elapsed-time (start end)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 "Copied from elp.el. Was elp-elapsed-time.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 Argument START and END bound the time being calculated."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (+ (* (- (car end) (car start)) 65536.0)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (- (car (cdr end)) (car (cdr start)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (/ (- (car (cdr (cdr end))) (car (cdr (cdr start)))) 1000000.0)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (defun cedet-utest-log-shutdown (title &optional errorcondition)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 "Shut-down a larger test suite.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 TITLE is the section that is done.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ERRORCONDITION is some error that may have occured durinig testing."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (let ((endtime (current-time))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (cedet-utest-log-shutdown-msg title cedet-utest-log-timer endtime)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (setq cedet-utest-log-timer nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (defun cedet-utest-log-shutdown-msg (title startime endtime)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 "Show a shutdown message with TITLE, STARTIME, and ENDTIME."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (progn
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (message "\n>> Test Suite %s ended at @ %s"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 title
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (format-time-string "%c" endtime))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (message " Elapsed Time %.2f Seconds\n"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (cedet-utest-elapsed-time startime endtime)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (insert "\n>> Test Suite " title " ended at @ "
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (format-time-string "%c" endtime) "\n"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 " Elapsed Time "
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (number-to-string
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (cedet-utest-elapsed-time startime endtime))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 " Seconds\n * "))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (defun cedet-utest-show-log-end ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 "Show the end of the current unit test log."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (unless (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (let* ((cb (current-buffer))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (cf (selected-frame))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (bw (or (get-buffer-window cedet-utest-buffer t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (get-buffer-window (switch-to-buffer cedet-utest-buffer) t)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (lf (window-frame bw))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (select-frame lf)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (select-window bw)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (select-frame cf)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (set-buffer cb)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 )))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (defun cedet-utest-post-command-hook ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 "Hook run after the current log command was run."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (message "")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (insert "\n\n")))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (setq cedet-utest-last-log-item nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (remove-hook 'post-command-hook 'cedet-utest-post-command-hook)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (defun cedet-utest-add-log-item-start (item)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 "Add ITEM into the log as being started."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (unless (equal item cedet-utest-last-log-item)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (setq cedet-utest-last-log-item item)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 ;; This next line makes sure we clear out status during logging.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (add-hook 'post-command-hook 'cedet-utest-post-command-hook)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (message " - Running %s ..." item)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (when (not (bolp)) (insert "\n"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (insert "Running " item " ... ")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (sit-for 0)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (cedet-utest-show-log-end)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (defun cedet-utest-add-log-item-done (&optional notes err precr)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 "Add into the log that the last item is done.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 Apply NOTES to the doneness of the log.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 Apply ERR if there was an error in previous item.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 Optional argument PRECR indicates to prefix the done msg w/ a newline."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 ;; Non-interactive-mode - show a message.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (if notes
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (message " * %s {%s}" (or err "done") notes)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (message " * %s" (or err "done")))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 ;; Interactive-mode - insert into the buffer.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (when precr (insert "\n"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (if err
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (insert err)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (insert "done")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (when notes (insert " (" notes ")")))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (insert "\n")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (setq cedet-utest-last-log-item nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (sit-for 0)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 )))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 ;;; INDIVIDUAL TEST API
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 ;; Use these APIs to start and log information.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 ;; The other fcns will be used to log across all the tests at once.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (defun cedet-utest-log-start (testname)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 "Setup the log for the test TESTNAME."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 ;; Make sure we have a log buffer.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (save-window-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (when (or (not cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (not (buffer-live-p cedet-utest-buffer))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (not (get-buffer-window cedet-utest-buffer t))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (cedet-utest-log-setup))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 ;; Add our startup message.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (cedet-utest-add-log-item-start testname)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (defun cedet-utest-log(format &rest args)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 "Log the text string FORMAT.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 The rest of the ARGS are used to fill in FORMAT with `format'."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (if (cedet-utest-noninteractive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (apply 'message format args)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (set-buffer cedet-utest-buffer)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (goto-char (point-max))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (when (not (bolp)) (insert "\n"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (insert (apply 'format format args))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (insert "\n")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (sit-for 0)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (cedet-utest-show-log-end)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;;; Inversion tests
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (defun inversion-unit-test ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 "Test inversion to make sure it can identify different version strings."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (let ((c1 (inversion-package-version 'inversion))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (c1i (inversion-package-incompatibility-version 'inversion))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (c2 (inversion-decode-version "1.3alpha2"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (c3 (inversion-decode-version "1.3beta4"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (c4 (inversion-decode-version "1.3 beta5"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (c5 (inversion-decode-version "1.3.4"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (c6 (inversion-decode-version "2.3alpha"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (c7 (inversion-decode-version "1.3"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (c8 (inversion-decode-version "1.3pre1"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (c9 (inversion-decode-version "2.4 (patch 2)"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (c10 (inversion-decode-version "2.4 (patch 3)"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (c11 (inversion-decode-version "2.4.2.1"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (c12 (inversion-decode-version "2.4.2.2"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (if (not (and
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (inversion-= c1 c1)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (inversion-< c1i c1)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (inversion-< c2 c3)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (inversion-< c3 c4)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (inversion-< c4 c5)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (inversion-< c5 c6)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (inversion-< c2 c4)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (inversion-< c2 c5)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (inversion-< c2 c6)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (inversion-< c3 c5)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (inversion-< c3 c6)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (inversion-< c7 c6)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (inversion-< c4 c7)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (inversion-< c2 c7)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (inversion-< c8 c6)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (inversion-< c8 c7)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (inversion-< c4 c8)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (inversion-< c2 c8)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (inversion-< c9 c10)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (inversion-< c10 c11)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (inversion-< c11 c12)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ;; Negatives
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (not (inversion-< c3 c2))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (not (inversion-< c4 c3))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (not (inversion-< c5 c4))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (not (inversion-< c6 c5))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (not (inversion-< c7 c2))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (not (inversion-< c7 c8))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (not (inversion-< c12 c11))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; Test the tester on inversion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (not (inversion-test 'inversion inversion-version))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;; Test that we throw an error
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (inversion-test 'inversion "0.0.0")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (inversion-test 'inversion "1000.0")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 (error "Inversion tests failed")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (message "Inversion tests passed."))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 ;;; cedet-files unit test
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (defvar cedet-files-utest-list
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 '(
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 ( "/home/me/src/myproj/src/foo.c" . "!home!me!src!myproj!src!foo.c" )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 ( "c:/work/myproj/foo.el" . "!drive_c!work!myproj!foo.el" )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 ( "//windows/proj/foo.java" . "!!windows!proj!foo.java" )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 ( "/home/me/proj!bang/foo.c" . "!home!me!proj!!bang!foo.c" )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 "List of different file names to test.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 Each entry is a cons cell of ( FNAME . CONVERTED )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 where FNAME is some file name, and CONVERTED is what it should be
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 converted into.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (defun cedet-files-utest ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 "Test out some file name conversions."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (let ((idx 0))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (dolist (FT cedet-files-utest-list)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (setq idx (+ idx 1))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (let ((dir->file (cedet-directory-name-to-file-name (car FT) t))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (file->dir (cedet-file-name-to-directory-name (cdr FT) t))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (unless (string= (cdr FT) dir->file)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (error "Failed: %d. Found: %S Wanted: %S"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 idx dir->file (cdr FT))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (unless (string= file->dir (car FT))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (error "Failed: %d. Found: %S Wanted: %S"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 idx file->dir (car FT)))))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;;; pulse test
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (defun pulse-test (&optional no-error)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 "Test the lightening function for pulsing a line.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 When optional NO-ERROR Don't throw an error if we can't run tests."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (if (or (not pulse-flag) (not (pulse-available-p)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (if no-error
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 (error (concat "Pulse test only works on versions of Emacs"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 " that support pulsing")))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 ;; Run the tests
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (when (interactive-p)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (message "<Press a key> Pulse one line.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (read-char))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (pulse-momentary-highlight-one-line (point))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (when (interactive-p)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 (message "<Press a key> Pulse a region.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (read-char))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 (pulse-momentary-highlight-region (point)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (condition-case nil
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 (forward-char 30)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 (error nil))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (point)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (when (interactive-p)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (message "<Press a key> Pulse line a specific color.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (read-char))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (pulse-momentary-highlight-one-line (point) 'modeline)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 (when (interactive-p)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (message "<Press a key> Pulse a pre-existing overlay.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (read-char))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 (let* ((start (point-at-bol))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (end (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (end-of-line)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (when (not (eobp))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (forward-char 1))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (point)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 (o (make-overlay start end))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 (pulse-momentary-highlight-overlay o)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (if (overlay-buffer o)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (delete-overlay o)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 (error "Non-temporary overlay was deleted!"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (when (interactive-p)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (message "Done!"))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (provide 'cedet-utests)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105267
diff changeset
515 ;; arch-tag: ace16290-4119-4df0-b33c-8c6b809f420d
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 ;;; cedet-utests.el ends here