aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEric Ludlam2019-10-14 20:43:28 -0400
committerStefan Monnier2019-10-15 11:08:18 -0400
commita99812ee0fb7245d4ee3a862f3139c0a53a8c5d7 (patch)
treea4d8af946c01ac7bce788d98af82d1900423a6ca /test
parent68df7d7069bb0e0a2e804b727fb0f993698c6c9c (diff)
downloademacs-a99812ee0fb7245d4ee3a862f3139c0a53a8c5d7.tar.gz
emacs-a99812ee0fb7245d4ee3a862f3139c0a53a8c5d7.zip
Convert manual CEDET tests from test/manual/cedet to be
automated tests in test/lisp/cedet. Author: Eric Ludlam <zappo@gnu.org>
Diffstat (limited to 'test')
-rw-r--r--test/lisp/cedet/semantic-utest-c.el181
-rw-r--r--test/lisp/cedet/semantic-utest-ia.el (renamed from test/manual/cedet/semantic-ia-utest.el)339
-rw-r--r--test/lisp/cedet/semantic-utest.el (renamed from test/manual/cedet/semantic-utest.el)200
-rw-r--r--test/manual/cedet/semantic-utest-c.el72
4 files changed, 370 insertions, 422 deletions
diff --git a/test/lisp/cedet/semantic-utest-c.el b/test/lisp/cedet/semantic-utest-c.el
new file mode 100644
index 00000000000..a6a5fd16257
--- /dev/null
+++ b/test/lisp/cedet/semantic-utest-c.el
@@ -0,0 +1,181 @@
1;;; semantic-utest-c.el --- C based parsing tests.
2
3;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
4
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6
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 3 of the License, or
12;; (at your option) 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. If not, see <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23;;
24;; Run some C based parsing tests.
25
26(require 'ert)
27(require 'semantic)
28
29(defvar semantic-utest-c-comparisons
30 '( ("testsppreplace.c" . "testsppreplaced.c")
31 )
32 "List of files to parse and compare against each other.")
33
34(defvar cedet-utest-directory
35 (let* ((C (file-name-directory (locate-library "cedet")))
36 (D (expand-file-name "../../test/manual/cedet/" C)))
37 D)
38 "Location of test files for this test suite.")
39
40(defvar semantic-utest-c-test-directory (expand-file-name "tests" cedet-utest-directory)
41 "Location of test files.")
42
43;;; Code:
44;;;###autoload
45(ert-deftest semantic-test-c-preprocessor-simulation ()
46 "Run parsing test for C from the test directory."
47 (interactive)
48 (semantic-mode 1)
49 (dolist (fp semantic-utest-c-comparisons)
50 (let* ((semantic-lex-c-nested-namespace-ignore-second nil)
51 (tags-actual
52 (save-excursion
53 (set-buffer (find-file-noselect (expand-file-name (car fp) semantic-utest-c-test-directory)))
54 (semantic-clear-toplevel-cache)
55 (semantic-fetch-tags)))
56 (tags-expected
57 (save-excursion
58 (set-buffer (find-file-noselect (expand-file-name (cdr fp) semantic-utest-c-test-directory)))
59 (semantic-clear-toplevel-cache)
60 (semantic-fetch-tags))))
61 (when (or (not tags-expected) (not tags-actual))
62 (message "Tried to find test files in: %s" semantic-utest-c-test-directory)
63 (error "Failed: Disovered no tags in test files or test file not found."))
64
65 ;; Now that we have the tags, compare them for SPP accuracy.
66 (dolist (tag tags-actual)
67 (if (and (semantic-tag-of-class-p tag 'variable)
68 (semantic-tag-variable-constant-p tag))
69 nil ; skip the macros.
70
71 (if (semantic-tag-similar-with-subtags-p tag (car tags-expected))
72 (setq tags-expected (cdr tags-expected))
73 (with-mode-local c-mode
74 (should nil) ;; this is a fail condition
75 (message "Error: Found: >> %s << Expected: >> %s <<"
76 (semantic-format-tag-prototype tag nil t)
77 (semantic-format-tag-prototype (car tags-expected) nil t)
78 )))
79 ))
80 )))
81
82(require 'semantic/bovine/gcc)
83
84;; Example output of "gcc -v"
85(defvar semantic-gcc-test-strings
86 '(;; My old box:
87 "Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
88Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
89Thread model: posix
90gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"
91 ;; Alex Ott:
92 "Using built-in specs.
93Target: i486-linux-gnu
94Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.1-9ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
95Thread model: posix
96gcc version 4.3.1 (Ubuntu 4.3.1-9ubuntu1)"
97 ;; My debian box:
98 "Using built-in specs.
99Target: x86_64-unknown-linux-gnu
100Configured with: ../../../sources/gcc/configure --prefix=/usr/local/glibc-2.3.6/x86_64/apps/gcc-4.2.3 --with-gmp=/usr/local/gcc/gmp --with-mpfr=/usr/local/gcc/mpfr --enable-languages=c,c++,fortran --with-as=/usr/local/glibc-2.3.6/x86_64/apps/gcc-4.2.3/bin/as --with-ld=/usr/local/glibc-2.3.6/x86_64/apps/gcc-4.2.3/bin/ld --disable-multilib
101Thread model: posix
102gcc version 4.2.3"
103 ;; My mac:
104 "Using built-in specs.
105Target: i686-apple-darwin8
106Configured with: /private/var/tmp/gcc/gcc-5341.obj~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --with-arch=pentium-m --with-tune=prescott --program-prefix= --host=i686-apple-darwin8 --target=i686-apple-darwin8
107Thread model: posix
108gcc version 4.0.1 (Apple Computer, Inc. build 5341)"
109 ;; Ubuntu Intrepid
110 "Using built-in specs.
111Target: x86_64-linux-gnu
112Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
113Thread model: posix
114gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)"
115 ;; Red Hat EL4
116 "Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
117Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
118Thread model: posix
119gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)"
120 ;; Red Hat EL5
121 "Using built-in specs.
122Target: x86_64-redhat-linux
123Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
124Thread model: posix
125gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)"
126 ;; David Engster's german gcc on ubuntu 4.3
127 "Es werden eingebaute Spezifikationen verwendet.
128Ziel: i486-linux-gnu
129Konfiguriert mit: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
130Thread-Modell: posix
131gcc-Version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)"
132 ;; Damien Deville bsd
133 "Using built-in specs.
134Target: i386-undermydesk-freebsd
135Configured with: FreeBSD/i386 system compiler
136Thread model: posix
137gcc version 4.2.1 20070719 [FreeBSD]"
138 )
139 "A bunch of sample gcc -v outputs from different machines.")
140
141(defvar semantic-gcc-test-strings-fail
142 '(;; A really old solaris box I found
143 "Reading specs from /usr/local/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
144gcc version 2.95.2 19991024 (release)"
145 )
146 "A bunch of sample gcc -v outputs that fail to provide the info we want.")
147
148(ert-deftest semantic-test-gcc-output-parser ()
149 "Test the output parser against some collected strings."
150 (let ((fail nil))
151 (dolist (S semantic-gcc-test-strings)
152 (let* ((fields (semantic-gcc-fields S))
153 (v (cdr (assoc 'version fields)))
154 (h (or (cdr (assoc 'target fields))
155 (cdr (assoc '--target fields))
156 (cdr (assoc '--host fields))))
157 (p (cdr (assoc '--prefix fields)))
158 )
159 ;; No longer test for prefixes.
160 (when (not (and v h))
161 (let ((strs (split-string S "\n")))
162 (message "Test failed on %S\nV H P:\n%S %S %S" (car strs) v h p)
163 ))
164 (should (and v h))
165 ))
166 (dolist (S semantic-gcc-test-strings-fail)
167 (let* ((fields (semantic-gcc-fields S))
168 (v (cdr (assoc 'version fields)))
169 (h (or (cdr (assoc '--host fields))
170 (cdr (assoc 'target fields))))
171 (p (cdr (assoc '--prefix fields)))
172 )
173 ;; negative test
174 (should-not (and v h p))
175 ))
176 ))
177
178
179(provide 'semantic-utest-c)
180
181;;; semantic-utest-c.el ends here
diff --git a/test/manual/cedet/semantic-ia-utest.el b/test/lisp/cedet/semantic-utest-ia.el
index 10f02b3c34c..f83a89a8683 100644
--- a/test/manual/cedet/semantic-ia-utest.el
+++ b/test/lisp/cedet/semantic-utest-ia.el
@@ -1,4 +1,4 @@
1;;; semantic-ia-utest.el --- Analyzer unit tests 1;;; semantic-utest-ia.el --- Analyzer unit tests
2 2
3;; Copyright (C) 2008-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
4 4
@@ -35,101 +35,77 @@
35(require 'semantic/symref) 35(require 'semantic/symref)
36(require 'semantic/symref/filter) 36(require 'semantic/symref/filter)
37 37
38(load-file "cedet-utests.el") 38(defvar cedet-utest-directory
39 39 (let* ((C (file-name-directory (locate-library "cedet")))
40(defvar semantic-ia-utest-file-list 40 (D (expand-file-name "../../test/manual/cedet/" C)))
41 '( 41 D)
42 "tests/testdoublens.cpp" 42 "Location of test files for this test suite.")
43 "tests/testsubclass.cpp" 43
44 "tests/testtypedefs.cpp" 44(defvar semantic-utest-test-directory (expand-file-name "tests" cedet-utest-directory)
45 "tests/testfriends.cpp" 45 "Location of test files.")
46 "tests/testnsp.cpp" 46
47 "tests/testsppcomplete.c" 47(ert-deftest semantic-utest-ia-doublens.cpp ()
48 "tests/testvarnames.c" 48 (let ((tst (expand-file-name "testdoublens.cpp" semantic-utest-test-directory)))
49 "tests/testjavacomp.java" 49 (should (file-exists-p tst))
50 ) 50 (should-not (semantic-ia-utest tst))))
51 "List of files with analyzer completion test points.") 51
52 52(ert-deftest semantic-utest-ia-subclass.cpp ()
53(defvar semantic-ia-utest-error-log-list nil 53 (let ((tst (expand-file-name "testsubclass.cpp" semantic-utest-test-directory)))
54 "List of errors occurring during a run.") 54 (should (file-exists-p tst))
55 55 (should-not (semantic-ia-utest tst))))
56;;;###autoload 56
57(defun semantic-ia-utest (&optional arg) 57(ert-deftest semantic-utest-ia-typedefs.cpp ()
58 "Run the semantic ia unit test against stored sources. 58 (let ((tst (expand-file-name "testtypedefs.cpp" semantic-utest-test-directory)))
59Argument ARG specifies which set of tests to run. 59 (should (file-exists-p tst))
60 1 - ia utests 60 (should-not (semantic-ia-utest tst))))
61 2 - regs utests 61
62 3 - symrefs utests 62(ert-deftest semantic-utest-ia-friends.cpp ()
63 4 - symref count utests" 63 (let ((tst (expand-file-name "testfriends.cpp" semantic-utest-test-directory)))
64 (interactive "P") 64 (should (file-exists-p tst))
65 (save-excursion 65 (should-not (semantic-ia-utest tst))))
66 66
67 (let ((fl semantic-ia-utest-file-list) 67(ert-deftest semantic-utest-ia-namespace.cpp ()
68 (semantic-ia-utest-error-log-list nil) 68 (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory)))
69 ) 69 (should (file-exists-p tst))
70 70 (should-not (semantic-ia-utest tst))))
71 (cedet-utest-log-setup "ANALYZER") 71
72 72(ert-deftest semantic-utest-ia-sppcomplete.c ()
73 (set-buffer (semantic-find-file-noselect 73 (let ((tst (expand-file-name "testsppcomplete.c" semantic-utest-test-directory)))
74 (or (locate-library "semantic-ia-utest.el") 74 (should (file-exists-p tst))
75 "semantic-ia-utest.el"))) 75 (should-not (semantic-ia-utest tst))))
76 76
77 (while fl 77(ert-deftest semantic-utest-ia-varnames.c ()
78 78 (let ((tst (expand-file-name "testvarnames.c" semantic-utest-test-directory)))
79 ;; Make sure we have the files we think we have. 79 (should (file-exists-p tst))
80 (when (not (file-exists-p (car fl))) 80 (should-not (semantic-ia-utest tst))))
81 (error "Cannot find unit test file: %s" (car fl))) 81
82 82(ert-deftest semantic-utest-ia-javacomp.java ()
83 ;; Run the tests. 83 (let ((tst (expand-file-name "testjavacomp.java" semantic-utest-test-directory)))
84 (let ((fb (find-buffer-visiting (car fl))) 84 (should (file-exists-p tst))
85 (b (semantic-find-file-noselect (car fl) t))) 85 (should-not (semantic-ia-utest tst))))
86 86
87 ;; Run the test on it. 87;;; Core testing utility
88 (save-excursion 88(defun semantic-ia-utest (testfile)
89 (set-buffer b) 89 "Run the semantic ia unit test against stored sources."
90 90 (semantic-mode 1)
91 ;; This line will also force the include, scope, and typecache. 91 (let ((b (semantic-find-file-noselect testfile t)))
92 (semantic-clear-toplevel-cache) 92
93 ;; Force tags to be parsed. 93 ;; Run the test on it.
94 (semantic-fetch-tags) 94 (with-current-buffer b
95 95
96 (semantic-ia-utest-log " ** Starting tests in %s" 96 ;; This line will also force the include, scope, and typecache.
97 (buffer-name)) 97 (semantic-clear-toplevel-cache)
98 98 ;; Force tags to be parsed.
99 (when (or (not arg) (= arg 1)) 99 (semantic-fetch-tags)
100 (semantic-ia-utest-buffer)) 100
101 101 (prog1
102 (when (or (not arg) (= arg 2)) 102 (or (semantic-ia-utest-buffer)
103 (set-buffer b) 103 (semantic-ia-utest-buffer-refs)
104 (semantic-ia-utest-buffer-refs)) 104 (semantic-sr-utest-buffer-refs)
105 105 (semantic-src-utest-buffer-refs))
106 (when (or (not arg) (= arg 3)) 106
107 (set-buffer b) 107 (kill-buffer b)
108 (semantic-sr-utest-buffer-refs)) 108 ))))
109
110 (when (or (not arg) (= arg 4))
111 (set-buffer b)
112 (semantic-src-utest-buffer-refs))
113
114 (semantic-ia-utest-log " ** Completed tests in %s\n"
115 (buffer-name))
116 )
117
118 ;; If it wasn't already in memory, whack it.
119 (when (not fb)
120 (kill-buffer b))
121 )
122 (setq fl (cdr fl)))
123
124 (cedet-utest-log-shutdown
125 "ANALYZER"
126 (when semantic-ia-utest-error-log-list
127 (format "%s Failures found."
128 (length semantic-ia-utest-error-log-list))))
129 (when semantic-ia-utest-error-log-list
130 (error "Failures found during analyzer unit tests"))
131 ))
132 )
133 109
134(defun semantic-ia-utest-buffer () 110(defun semantic-ia-utest-buffer ()
135 "Run analyzer completion unit-test pass in the current buffer." 111 "Run analyzer completion unit-test pass in the current buffer."
@@ -148,6 +124,7 @@ Argument ARG specifies which set of tests to run.
148 (semanticdb-find-default-throttle 124 (semanticdb-find-default-throttle
149 (remq 'system semanticdb-find-default-throttle)) 125 (remq 'system semanticdb-find-default-throttle))
150 ) 126 )
127
151 ;; Keep looking for test points until we run out. 128 ;; Keep looking for test points until we run out.
152 (while (save-excursion 129 (while (save-excursion
153 (setq regex-p (concat "//\\s-*-" (number-to-string idx) "-" ) 130 (setq regex-p (concat "//\\s-*-" (number-to-string idx) "-" )
@@ -182,29 +159,19 @@ Argument ARG specifies which set of tests to run.
182 159
183 (if (equal actual desired) 160 (if (equal actual desired)
184 (setq pass (cons idx pass)) 161 (setq pass (cons idx pass))
185 (setq fail (cons idx fail)) 162 (setq fail (cons
186 (semantic-ia-utest-log 163 (list
187 " Failed %d. Desired: %S Actual %S" 164 (format "Failed %d. Desired: %S Actual %S"
188 idx desired actual) 165 idx desired actual)
189 (add-to-list 'semantic-ia-utest-error-log-list 166 )
190 (list (buffer-name) idx desired actual) 167 fail)))
191 )
192
193 )
194 )
195 168
196 (setq p nil a nil) 169 (setq p nil a nil)
197 (setq idx (1+ idx))) 170 (setq idx (1+ idx)))
171 )
198 172
199 (if fail 173 (when fail
200 (progn 174 (cons "COMPLETION SUBTEST" fail))
201 (semantic-ia-utest-log
202 " Unit tests (completions) failed tests %S"
203 (reverse fail))
204 )
205 (semantic-ia-utest-log " Unit tests (completions) passed (%d total)"
206 (- idx 1)))
207
208 )) 175 ))
209 176
210(defun semantic-ia-utest-buffer-refs () 177(defun semantic-ia-utest-buffer-refs ()
@@ -287,34 +254,22 @@ Argument ARG specifies which set of tests to run.
287 (throw 'failed t) 254 (throw 'failed t)
288 ))) 255 )))
289 256
290 (if (not pf) 257 (if (not pf)
291 ;; We passed 258 ;; We passed
292 (setq pass (cons idx pass)) 259 (setq pass (cons idx pass))
293 ;; We failed. 260 ;; We failed.
294 (setq fail (cons idx fail)) 261 (setq fail (cons
295 (semantic-ia-utest-log 262 (list
296 " Failed %d. For %s (Num impls %d) (Num protos %d)" 263 (message "Test id %d. For %s (Num impls %d) (Num protos %d)"
297 idx (if ct (semantic-tag-name ct) "<No tag found>") 264 idx (if ct (semantic-tag-name ct) "<No tag found>")
298 (length impl) (length proto)) 265 (length impl) (length proto))
299 (add-to-list 'semantic-ia-utest-error-log-list 266 )
300 (list (buffer-name) idx) 267 fail))
301 )
302 )) 268 ))
303
304 (setq p nil) 269 (setq p nil)
305 (setq idx (1+ idx)) 270 (setq idx (1+ idx))))
306 271 (when fail
307 )) 272 (cons "ANALYZER REF COUNTING SUBTEST" fail))))
308
309 (if fail
310 (progn
311 (semantic-ia-utest-log
312 " Unit tests (refs) failed tests")
313 )
314 (semantic-ia-utest-log " Unit tests (refs) passed (%d total)"
315 (- idx 1)))
316
317 ))
318 273
319(defun semantic-sr-utest-buffer-refs () 274(defun semantic-sr-utest-buffer-refs ()
320 "Run a symref unit-test pass in the current buffer." 275 "Run a symref unit-test pass in the current buffer."
@@ -358,14 +313,7 @@ Argument ARG specifies which set of tests to run.
358 (if (not actual-result) 313 (if (not actual-result)
359 (progn 314 (progn
360 (setq fail (cons idx fail)) 315 (setq fail (cons idx fail))
361 (semantic-ia-utest-log 316 (message "Failed Tool: %s" (eieio-object-name symref-tool-used))
362 " Failed FNames %d: No results." idx)
363 (semantic-ia-utest-log
364 " Failed Tool: %s" (object-name symref-tool-used))
365
366 (add-to-list 'semantic-ia-utest-error-log-list
367 (list (buffer-name) idx)
368 )
369 ) 317 )
370 318
371 (setq actual (list (sort (mapcar 319 (setq actual (list (sort (mapcar
@@ -383,38 +331,28 @@ Argument ARG specifies which set of tests to run.
383 ;; We passed 331 ;; We passed
384 (setq pass (cons idx pass)) 332 (setq pass (cons idx pass))
385 ;; We failed. 333 ;; We failed.
386 (setq fail (cons idx fail)) 334 (setq fail
387 (when (not (equal (car actual) (car desired))) 335 (cons (list
388 (semantic-ia-utest-log 336 (when (not (equal (car actual) (car desired)))
389 " Failed FNames %d: Actual: %S Desired: %S" 337 (list
390 idx (car actual) (car desired)) 338 (format "Actual: %S Desired: %S"
391 (semantic-ia-utest-log 339 (car actual) (car desired))
392 " Failed Tool: %s" (object-name symref-tool-used)) 340 (format "Failed Tool: %s" (eieio-object-name symref-tool-used))
393 ) 341 ))
394 (when (not (equal (car (cdr actual)) (car (cdr desired)))) 342 (when (not (equal (car (cdr actual)) (car (cdr desired))))
395 (semantic-ia-utest-log 343 (list (format
396 " Failed TNames %d: Actual: %S Desired: %S" 344 "Actual: %S Desired: %S"
397 idx (car (cdr actual)) (car (cdr desired))) 345 (car (cdr actual)) (car (cdr desired)))
398 (semantic-ia-utest-log 346 (format
399 " Failed Tool: %s" (object-name symref-tool-used)) 347 "Failed Tool: %s" (eieio-object-name symref-tool-used)))))
400 ) 348 fail))
401 (add-to-list 'semantic-ia-utest-error-log-list
402 (list (buffer-name) idx)
403 )
404 )) 349 ))
405 350
406 (setq idx (1+ idx)) 351 (setq idx (1+ idx))
407 (setq tag nil)) 352 (setq tag nil))
408 353
409 (if fail 354 (when fail
410 (progn 355 (cons "SYMREF SUBTEST" fail))))
411 (semantic-ia-utest-log
412 " Unit tests (symrefs) failed tests")
413 )
414 (semantic-ia-utest-log " Unit tests (symrefs) passed (%d total)"
415 (- idx 1)))
416
417 ))
418 356
419(defun semantic-symref-test-count-hits-in-tag () 357(defun semantic-symref-test-count-hits-in-tag ()
420 "Lookup in the current tag the symbol under point. 358 "Lookup in the current tag the symbol under point.
@@ -431,10 +369,6 @@ tag that contains point, and return that."
431 target (lambda (start end prefix) (setq Lcount (1+ Lcount))) 369 target (lambda (start end prefix) (setq Lcount (1+ Lcount)))
432 (semantic-tag-start tag) 370 (semantic-tag-start tag)
433 (semantic-tag-end tag)) 371 (semantic-tag-end tag))
434 (when (interactive-p)
435 (message "Found %d occurrences of %s in %.2f seconds"
436 Lcount (semantic-tag-name target)
437 (semantic-elapsed-time start nil)))
438 Lcount))) 372 Lcount)))
439 373
440(defun semantic-src-utest-buffer-refs () 374(defun semantic-src-utest-buffer-refs ()
@@ -474,54 +408,33 @@ tag that contains point, and return that."
474 408
475 (if (not actual) 409 (if (not actual)
476 (progn 410 (progn
477 (setq fail (cons idx fail)) 411 (setq fail (cons
478 (semantic-ia-utest-log 412 (list
479 " Failed symref count %d: No results." idx) 413 (format
414 "Symref id %d: No results." idx))
415 fail))
480 416
481 (add-to-list 'semantic-ia-utest-error-log-list
482 (list (buffer-name) idx)
483 )
484 ) 417 )
485 418
486 (if (equal desired actual) 419 (if (equal desired actual)
487 ;; We passed 420 ;; We passed
488 (setq pass (cons idx pass)) 421 (setq pass (cons idx pass))
489 ;; We failed. 422 ;; We failed.
490 (setq fail (cons idx fail)) 423 (setq fail (cons (list
491 (when (not (equal actual desired)) 424 (when (not (equal actual desired))
492 (semantic-ia-utest-log 425 (format
493 " Failed symref count %d: Actual: %S Desired: %S" 426 "Symref id %d: Actual: %S Desired: %S"
494 idx actual desired) 427 idx actual desired)
495 ) 428 )
496 429 )
497 (add-to-list 'semantic-ia-utest-error-log-list 430 fail))
498 (list (buffer-name) idx)
499 )
500 )) 431 ))
501 432
502 (setq idx (1+ idx)) 433 (setq idx (1+ idx))
503 ) 434 )
504 435
505 (if fail 436 (when fail
506 (progn 437 (cons "SYMREF COUNTING SUBTEST" fail))))
507 (semantic-ia-utest-log
508 " Unit tests (symrefs counter) failed tests")
509 )
510 (semantic-ia-utest-log " Unit tests (symrefs counter) passed (%d total)"
511 (- idx 1)))
512
513 ))
514
515(defun semantic-ia-utest-start-log ()
516 "Start up a testlog for a run."
517 ;; Redo w/ CEDET utest framework.
518 (cedet-utest-log-start "semantic: analyzer tests"))
519
520(defun semantic-ia-utest-log (&rest args)
521 "Log some test results.
522Pass ARGS to format to create the log message."
523 ;; Forward to CEDET utest framework.
524 (apply 'cedet-utest-log args))
525 438
526(provide 'semantic-ia-utest) 439(provide 'semantic-ia-utest)
527 440
diff --git a/test/manual/cedet/semantic-utest.el b/test/lisp/cedet/semantic-utest.el
index 102c1283558..7303c0ef092 100644
--- a/test/manual/cedet/semantic-utest.el
+++ b/test/lisp/cedet/semantic-utest.el
@@ -26,9 +26,17 @@
26;; and full reparsing system, and anything else I may feel the urge 26;; and full reparsing system, and anything else I may feel the urge
27;; to write a test for. 27;; to write a test for.
28 28
29(require 'cedet)
29(require 'semantic) 30(require 'semantic)
30 31
31(load-file "cedet-utests.el") 32(defvar cedet-utest-directory
33 (let* ((C (file-name-directory (locate-library "cedet")))
34 (D (expand-file-name "../../test/manual/cedet/" C)))
35 D)
36 "Location of test files for this test suite.")
37
38(defvar semantic-utest-test-directory (expand-file-name "tests" cedet-utest-directory)
39 "Location of test files.")
32 40
33(defvar semantic-utest-temp-directory (if (fboundp 'temp-directory) 41(defvar semantic-utest-temp-directory (if (fboundp 'temp-directory)
34 (temp-directory) 42 (temp-directory)
@@ -332,8 +340,8 @@ t2:t1 #1
332 " 340 "
333 (define fun1 2) 341 (define fun1 2)
334 342
335 (define fun2 3 ;1 343 (define fun2 3) ;1
336 ) 344
337") 345")
338 346
339(defvar semantic-utest-Scheme-name-contents 347(defvar semantic-utest-Scheme-name-contents
@@ -493,9 +501,9 @@ Pre-fill the buffer with CONTENTS."
493 ) 501 )
494 ) 502 )
495 503
496(defun semantic-utest-C () 504(ert-deftest semantic-utest-C ()
497 "Run semantic's C unit test." 505 "Run semantic's C unit test."
498 (interactive) 506 (semantic-mode 1)
499 (save-excursion 507 (save-excursion
500 (let ((buff (semantic-utest-makebuffer semantic-utest-C-filename semantic-utest-C-buffer-contents)) 508 (let ((buff (semantic-utest-makebuffer semantic-utest-C-filename semantic-utest-C-buffer-contents))
501 (buff2 (semantic-utest-makebuffer semantic-utest-C-filename-h semantic-utest-C-h-buffer-contents)) 509 (buff2 (semantic-utest-makebuffer semantic-utest-C-filename-h semantic-utest-C-h-buffer-contents))
@@ -512,24 +520,19 @@ Pre-fill the buffer with CONTENTS."
512 ;; Update tags, and show it. 520 ;; Update tags, and show it.
513 (semantic-fetch-tags) 521 (semantic-fetch-tags)
514 522
515 (switch-to-buffer buff)
516 (sit-for 0)
517
518 ;; Run the tests. 523 ;; Run the tests.
519 ;;(message "First parsing test.") 524 ;;(message "First parsing test.")
520 (semantic-utest-verify-names semantic-utest-C-name-contents) 525 (should (semantic-utest-verify-names semantic-utest-C-name-contents))
521 526
522 ;;(message "Invalid tag test.") 527 ;;(message "Invalid tag test.")
523 (semantic-utest-last-invalid semantic-utest-C-name-contents '("fun2") "/\\*1\\*/" "/* Deleted this line */") 528 (semantic-utest-last-invalid semantic-utest-C-name-contents '("fun2") "/\\*1\\*/" "/* Deleted this line */")
524 (semantic-utest-verify-names semantic-utest-C-name-contents) 529 (should (semantic-utest-verify-names semantic-utest-C-name-contents))
525 530
526 (set-buffer-modified-p nil) 531 (set-buffer-modified-p nil)
527 ;; Clean up 532 ;; Clean up
528 ;; (kill-buffer buff) 533 (kill-buffer buff)
529 ;; (kill-buffer buff2) 534 (kill-buffer buff2)
530 )) 535 )))
531 (message "All C tests passed.")
532 )
533 536
534 537
535 538
@@ -544,6 +547,7 @@ NAME-CONTENTS is the list of names that should be in the contents.
544NAMES-REMOVED is the list of names that gets removed in the removal step. 547NAMES-REMOVED is the list of names that gets removed in the removal step.
545KILLME is the name of items to be killed. 548KILLME is the name of items to be killed.
546INSERTME is the text to be inserted after the deletion." 549INSERTME is the text to be inserted after the deletion."
550 (semantic-mode 1)
547 (save-excursion 551 (save-excursion
548 (let ((buff (semantic-utest-makebuffer filename contents)) 552 (let ((buff (semantic-utest-makebuffer filename contents))
549 ) 553 )
@@ -554,79 +558,69 @@ INSERTME is the text to be inserted after the deletion."
554 (semantic-highlight-edits-mode 1) 558 (semantic-highlight-edits-mode 1)
555 559
556 ;; Update tags, and show it. 560 ;; Update tags, and show it.
561 (semantic-clear-toplevel-cache)
557 (semantic-fetch-tags) 562 (semantic-fetch-tags)
558 (switch-to-buffer buff) 563 (switch-to-buffer buff)
559 (sit-for 0) 564 (sit-for 0)
560 565
561 ;; Run the tests. 566 ;; Run the tests.
562 ;;(message "First parsing test %s." testname) 567 ;;(message "First parsing test %s." testname)
563 (semantic-utest-verify-names name-contents) 568 (should (semantic-utest-verify-names name-contents))
564 569
565 ;;(message "Invalid tag test %s." testname) 570 ;;(message "Invalid tag test %s." testname)
566 (semantic-utest-last-invalid name-contents names-removed killme insertme) 571 (semantic-utest-last-invalid name-contents names-removed killme insertme)
567 (semantic-utest-verify-names name-contents) 572 (should (semantic-utest-verify-names name-contents))
568 573
569 (set-buffer-modified-p nil) 574 (set-buffer-modified-p nil)
570 ;; Clean up 575 ;; Clean up
571 ;; (kill-buffer buff) 576 (kill-buffer buff)
572 )) 577 )))
573 (message "All %s tests passed." testname)
574 )
575 578
576(defun semantic-utest-Python() 579(ert-deftest semantic-utest-Python()
577 (interactive) 580 (skip-unless (featurep 'python-mode))
578 (if (fboundp 'python-mode) 581 (let ((python-indent-guess-indent-offset nil))
579 (semantic-utest-generic "Python" (semantic-utest-fname "pytest.py") semantic-utest-Python-buffer-contents semantic-utest-Python-name-contents '("fun2") "#1" "#deleted line") 582 (semantic-utest-generic "Python" (semantic-utest-fname "pytest.py") semantic-utest-Python-buffer-contents semantic-utest-Python-name-contents '("fun2") "#1" "#deleted line")
580 (message "Skilling Python test: NO major mode.")) 583 ))
581 )
582 584
583 585
584(defun semantic-utest-Javascript() 586(ert-deftest semantic-utest-Javascript()
585 (interactive)
586 (if (fboundp 'javascript-mode) 587 (if (fboundp 'javascript-mode)
587 (semantic-utest-generic "Javascript" (semantic-utest-fname "javascripttest.js") semantic-utest-Javascript-buffer-contents semantic-utest-Javascript-name-contents '("fun2") "//1" "//deleted line") 588 (semantic-utest-generic "Javascript" (semantic-utest-fname "javascripttest.js") semantic-utest-Javascript-buffer-contents semantic-utest-Javascript-name-contents '("fun2") "//1" "//deleted line")
588 (message "Skipping JavaScript test: NO major mode.")) 589 (message "Skipping JavaScript test: NO major mode."))
589 ) 590 )
590 591
591(defun semantic-utest-Java() 592(ert-deftest semantic-utest-Java()
592 (interactive)
593 ;; If JDE is installed, it might mess things up depending on the version 593 ;; If JDE is installed, it might mess things up depending on the version
594 ;; that was installed. 594 ;; that was installed.
595 (let ((auto-mode-alist '(("\\.java\\'" . java-mode)))) 595 (let ((auto-mode-alist '(("\\.java\\'" . java-mode))))
596 (semantic-utest-generic "Java" (semantic-utest-fname "JavaTest.java") semantic-utest-Java-buffer-contents semantic-utest-Java-name-contents '("fun2") "//1" "//deleted line") 596 (semantic-utest-generic "Java" (semantic-utest-fname "JavaTest.java") semantic-utest-Java-buffer-contents semantic-utest-Java-name-contents '("fun2") "//1" "//deleted line")
597 )) 597 ))
598 598
599(defun semantic-utest-Makefile() 599(ert-deftest semantic-utest-Makefile()
600 (interactive)
601 (semantic-utest-generic "Makefile" (semantic-utest-fname "Makefile") semantic-utest-Makefile-buffer-contents semantic-utest-Makefile-name-contents '("fun2") "#1" "#deleted line") 600 (semantic-utest-generic "Makefile" (semantic-utest-fname "Makefile") semantic-utest-Makefile-buffer-contents semantic-utest-Makefile-name-contents '("fun2") "#1" "#deleted line")
602 ) 601 )
603 602
604(defun semantic-utest-Scheme() 603(ert-deftest semantic-utest-Scheme()
605 (interactive) 604 (skip-unless nil) ;; There is a bug w/ scheme parser. Skip this for now.
606 (semantic-utest-generic "Scheme" (semantic-utest-fname "tst.scm") semantic-utest-Scheme-buffer-contents semantic-utest-Scheme-name-contents '("fun2") ";1" ";deleted line") 605 (semantic-utest-generic "Scheme" (semantic-utest-fname "tst.scm") semantic-utest-Scheme-buffer-contents semantic-utest-Scheme-name-contents '("fun2") ";1" ";deleted line")
607 ) 606 )
608 607
609 608
610(defun semantic-utest-Html() 609(ert-deftest semantic-utest-Html()
611 (interactive)
612 ;; Disable html-helper auto-fill-in mode. 610 ;; Disable html-helper auto-fill-in mode.
613 (let ((html-helper-build-new-buffer nil)) 611 (let ((html-helper-build-new-buffer nil))
614 (semantic-utest-generic "HTML" (semantic-utest-fname "tst.html") semantic-utest-Html-buffer-contents semantic-utest-Html-name-contents '("fun2") "<!--1-->" "<!--deleted line-->") 612 (semantic-utest-generic "HTML" (semantic-utest-fname "tst.html") semantic-utest-Html-buffer-contents semantic-utest-Html-name-contents '("fun2") "<!--1-->" "<!--deleted line-->")
615 )) 613 ))
616 614
617(defun semantic-utest-PHP() 615(ert-deftest semantic-utest-PHP()
618 (interactive) 616 (skip-unless (featurep 'php-mode))
619 (if (fboundp 'php-mode) 617 (semantic-utest-generic "PHP" (semantic-utest-fname "phptest.php") semantic-utest-PHP-buffer-contents semantic-utest-PHP-name-contents '("fun1") "fun2" "%^@")
620 (semantic-utest-generic "PHP" (semantic-utest-fname "phptest.php") semantic-utest-PHP-buffer-contents semantic-utest-PHP-name-contents '("fun1") "fun2" "%^@")
621 (message "Skipping PHP Test. No php-mode loaded."))
622 ) 618 )
623 619
624;look at http://mfgames.com/linux/csharp-mode 620;look at http://mfgames.com/linux/csharp-mode
625(defun semantic-utest-Csharp() ;; hmm i don't even know how to edit a scharp file. need a csharp mode implementation i suppose 621(ert-deftest semantic-utest-Csharp() ;; hmm i don't even know how to edit a scharp file. need a csharp mode implementation i suppose
626 (interactive) 622 (skip-unless (featurep 'csharp-mode))
627 (if (fboundp 'csharp-mode) 623 (semantic-utest-generic "C#" (semantic-utest-fname "csharptest.cs") semantic-utest-Csharp-buffer-contents semantic-utest-Csharp-name-contents '("fun2") "//1" "//deleted line")
628 (semantic-utest-generic "C#" (semantic-utest-fname "csharptest.cs") semantic-utest-Csharp-buffer-contents semantic-utest-Csharp-name-contents '("fun2") "//1" "//deleted line")
629 (message "Skipping C# test. No csharp-mode loaded."))
630 ) 624 )
631 625
632;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 626;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -653,32 +647,6 @@ INSERTME is the text to be inserted after the deletion."
653 647
654;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 648;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
655 649
656;;;###autoload
657(defun semantic-utest-main()
658 (interactive)
659 "call all utests"
660 (cedet-utest-log-start "multi-lang parsing")
661 (cedet-utest-log " * C tests...")
662 (semantic-utest-C)
663 (cedet-utest-log " * Python tests...")
664 (semantic-utest-Python)
665 (cedet-utest-log " * Java tests...")
666 (semantic-utest-Java)
667 (cedet-utest-log " * Javascript tests...")
668 (semantic-utest-Javascript)
669 (cedet-utest-log " * Makefile tests...")
670 (semantic-utest-Makefile)
671 (cedet-utest-log " * Scheme tests...")
672 (semantic-utest-Scheme)
673 (cedet-utest-log " * Html tests...")
674 (semantic-utest-Html)
675 (cedet-utest-log " * PHP tests...")
676 (semantic-utest-PHP)
677 (cedet-utest-log " * Csharp tests...")
678 (semantic-utest-Csharp)
679
680 (cedet-utest-log-shutdown "multi-lang parsing")
681 )
682 650
683;;; Buffer contents validation 651;;; Buffer contents validation
684;; 652;;
@@ -724,21 +692,25 @@ SKIPNAMES is a list of names that should be skipped in the NAMES list."
724 (while SN 692 (while SN
725 (setq names (remove (car SN) names)) 693 (setq names (remove (car SN) names))
726 (setq SN (cdr SN)))) 694 (setq SN (cdr SN))))
727 (while (and names table) 695 (catch 'utest-err
728 (if (not (semantic-utest-equivalent-tag-p (car names) 696 (while (and names table)
729 (car table) 697 (when (not (semantic-utest-equivalent-tag-p (car names)
730 skipnames)) 698 (car table)
731 (error "Expected %s, found %s" 699 skipnames))
732 (semantic-format-tag-prototype (car names)) 700 (message "Semantic Parse Test Fail: Expected %s, found %s"
733 (semantic-format-tag-prototype (car table)))) 701 (semantic-format-tag-prototype (car names))
734 (setq names (cdr names) 702 (semantic-format-tag-prototype (car table)))
735 table (cdr table))) 703 (throw 'utest-err nil)
736 (when names (error "Items forgotten: %S" 704 )
737 (mapcar 'semantic-tag-name names) 705 (setq names (cdr names)
738 )) 706 table (cdr table)))
739 (when table (error "Items extra: %S" 707 (when names
740 (mapcar 'semantic-tag-name table))) 708 (message "Semantic Parse Test Fail: Items forgotten: %S" (mapcar 'semantic-tag-name names))
741 t) 709 (throw 'utest-err nil))
710 (when table
711 (message "Semantic parse Test Fail: Items extra: %S" (mapcar 'semantic-tag-name table))
712 (throw 'utest-err nil))
713 t))
742 714
743(defun semantic-utest-verify-names (name-contents &optional skipnames) 715(defun semantic-utest-verify-names (name-contents &optional skipnames)
744 "Verify the names of the test buffer from NAME-CONTENTS. 716 "Verify the names of the test buffer from NAME-CONTENTS.
@@ -778,6 +750,9 @@ SKIPNAMES is a list of names to remove from NAME-CONTENTS"
778 750
779;;; Kill indicator line 751;;; Kill indicator line
780;; 752;;
753;; Utilities to modify the buffer for reparse, making sure a specific tag is deleted
754;; via the incremental parser.
755
781(defvar semantic-utest-last-kill-text nil 756(defvar semantic-utest-last-kill-text nil
782 "The text from the last kill.") 757 "The text from the last kill.")
783 758
@@ -806,9 +781,6 @@ SKIPNAMES is a list of names to remove from NAME-CONTENTS"
806 (sit-for 0) 781 (sit-for 0)
807 ) 782 )
808 783
809;;; EDITING TESTS
810;;
811
812(defun semantic-utest-last-invalid (name-contents names-removed killme insertme) 784(defun semantic-utest-last-invalid (name-contents names-removed killme insertme)
813 "Make the last fcn invalid." 785 "Make the last fcn invalid."
814 (semantic-utest-kill-indicator killme insertme) 786 (semantic-utest-kill-indicator killme insertme)
@@ -818,50 +790,4 @@ SKIPNAMES is a list of names to remove from NAME-CONTENTS"
818 790
819 791
820 792
821
822;"#<overlay from \\([0-9]+\\) to \\([0-9]+\\) in \\([^>]*\\)>"
823;#<overlay from \([0-9]+\) to \([0-9]+\) in \([^>]*\)>
824;(overlay \1 \2 "\3")
825
826
827;; JAVE
828;; these are some unit tests for cedet that I got from Eric and modified a bit for:
829;; python
830;; javascript
831;; java
832;; I tried to generalize the structure of the tests a bit to make it easier to add languages
833
834;; Mail from Eric:
835;; Many items in the checklist look like:
836
837;; M-x global-semantic-highlight-edits-mode RET
838;; - Edit a file. See the highlight of newly inserted text.
839;; - Customize `semantic-edits-verbose-flag' to be non-nil.
840;; - Wait for the idle scheduler, it should clean up the edits.
841;; - observe messages from incremental parser. Do they relate
842;; to the edits?
843;; - M-x bovinate RET - verify your changes are reflected.
844
845;; It's all about watching the behavior. Timers go off, things get
846;; cleaned up, you type in new changes, etc. An example I tried to
847;; do is below, but covers only 1 language, and not very well at that.
848;; I seem to remember seeing a unit test framework going by one of the
849;; lists. I'm not sure if that would help.
850
851;; Another that might be automatable:
852
853;; M-x semantic-analyze-current-context RET
854;; - Do this in different contexts in your language
855;; files. Verify that reasonable results are returned
856;; such as identification of assignments, function arguments, etc.
857
858;; Anyway, those are some ideas. Any effort you put it will be helpful!
859
860;; Thanks
861;; Eric
862
863;; -----------
864
865
866
867;;; semantic-utest.el ends here 793;;; semantic-utest.el ends here
diff --git a/test/manual/cedet/semantic-utest-c.el b/test/manual/cedet/semantic-utest-c.el
deleted file mode 100644
index a79c7c8822a..00000000000
--- a/test/manual/cedet/semantic-utest-c.el
+++ /dev/null
@@ -1,72 +0,0 @@
1;;; semantic-utest-c.el --- C based parsing tests.
2
3;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
4
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6
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 3 of the License, or
12;; (at your option) 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. If not, see <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23;;
24;; Run some C based parsing tests.
25
26(require 'semantic)
27
28(defvar semantic-utest-c-comparisons
29 '( ("testsppreplace.c" . "testsppreplaced.c")
30 )
31 "List of files to parse and compare against each other.")
32
33;;; Code:
34;;;###autoload
35(defun semantic-utest-c ()
36 "Run parsing test for C from the test directory."
37 (interactive)
38 (dolist (fp semantic-utest-c-comparisons)
39 (let* ((sem (locate-library "semantic"))
40 (sdir (file-name-directory sem))
41 (semantic-lex-c-nested-namespace-ignore-second nil)
42 (tags-actual
43 (save-excursion
44 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp)) sdir)))
45 (semantic-clear-toplevel-cache)
46 (semantic-fetch-tags)))
47 (tags-expected
48 (save-excursion
49 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (cdr fp)) sdir)))
50 (semantic-clear-toplevel-cache)
51 (semantic-fetch-tags))))
52 ;; Now that we have the tags, compare them for SPP accuracy.
53 (dolist (tag tags-actual)
54 (if (and (semantic-tag-of-class-p tag 'variable)
55 (semantic-tag-variable-constant-p tag))
56 nil ; skip the macros.
57 (if (semantic-tag-similar-with-subtags-p tag (car tags-expected))
58 (setq tags-expected (cdr tags-expected))
59 (with-mode-local c-mode
60 (error "Found: >> %s << Expected: >> %s <<"
61 (semantic-format-tag-prototype tag nil t)
62 (semantic-format-tag-prototype (car tags-expected) nil t)
63 )))
64 ))
65 ;; Passed?
66 (message "PASSED!")
67 )))
68
69
70(provide 'semantic-utest-c)
71
72;;; semantic-utest-c.el ends here