Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / test / automated / compile-tests.el
blob6c169eeab6484f92fd2828932cd850d2b250bc4e
1 ;;; compile-tests.el --- Test suite for font parsing.
3 ;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
5 ;; Author: Chong Yidong <cyd@stupidchicken.com>
6 ;; Keywords: internal
7 ;; Human-Keywords: internal
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Code:
26 (require 'ert)
27 (require 'compile)
29 (defvar compile-tests--test-regexps-data
30 ;; The computed column numbers are zero-indexed, so subtract 1 from
31 ;; what's reported in the string. The end column numbers are for
32 ;; the character after, so it matches what's reported in the string.
33 '(;; absoft
34 ("Error on line 3 of t.f: Execution error unclassifiable statement"
35 1 nil 3 "t.f")
36 ("Line 45 of \"foo.c\": bloofle undefined"
37 1 nil 45 "foo.c")
38 ("error on line 19 of fplot.f: spelling error?"
39 1 nil 19 "fplot.f")
40 ("warning on line 17 of fplot.f: data type is undefined for variable d"
41 1 nil 17 "fplot.f")
42 ;; Ada & Mpatrol
43 ("foo.adb:61:11: [...] in call to size declared at foo.ads:11"
44 1 11 61 "foo.adb")
45 ("foo.adb:61:11: [...] in call to size declared at foo.ads:11"
46 52 nil 11 "foo.ads")
47 (" 0x8008621 main+16 at error.c:17"
48 23 nil 17 "error.c")
49 ;; aix
50 ("****** Error number 140 in line 8 of file errors.c ******"
51 25 nil 8 "errors.c")
52 ;; ant
53 ("[javac] /src/DataBaseTestCase.java:27: unreported exception ..."
54 13 nil 27 "/src/DataBaseTestCase.java")
55 ("[javac] /src/DataBaseTestCase.java:49: warning: finally clause cannot complete normally"
56 13 nil 49 "/src/DataBaseTestCase.java")
57 ("[jikes] foo.java:3:5:7:9: blah blah"
58 14 (5 . 10) (3 . 7) "foo.java")
59 ;; bash
60 ("a.sh: line 1: ls-l: command not found"
61 1 nil 1 "a.sh")
62 ;; borland
63 ("Error ping.c 15: Unable to open include file 'sys/types.h'"
64 1 nil 15 "ping.c")
65 ("Warning pong.c 68: Call to function 'func' with no prototype"
66 1 nil 68 "pong.c")
67 ("Error E2010 ping.c 15: Unable to open include file 'sys/types.h'"
68 1 nil 15 "ping.c")
69 ("Warning W1022 pong.c 68: Call to function 'func' with no prototype"
70 1 nil 68 "pong.c")
71 ;; caml
72 ("File \"foobar.ml\", lines 5-8, characters 20-155: blah blah"
73 1 (20 . 156) (5 . 8) "foobar.ml")
74 ("File \"F:\\ocaml\\sorting.ml\", line 65, characters 2-145:\nWarning 26: unused variable equ."
75 1 (2 . 146) 65 "F:\\ocaml\\sorting.ml")
76 ("File \"/usr/share/gdesklets/display/TargetGauge.py\", line 41, in add_children"
77 1 nil 41 "/usr/share/gdesklets/display/TargetGauge.py")
78 ("File \\lib\\python\\Products\\PythonScripts\\PythonScript.py, line 302, in _exec"
79 1 nil 302 "\\lib\\python\\Products\\PythonScripts\\PythonScript.py")
80 ("File \"/tmp/foo.py\", line 10"
81 1 nil 10 "/tmp/foo.py")
82 ;; comma
83 ("\"foo.f\", line 3: Error: syntax error near end of statement"
84 1 nil 3 "foo.f")
85 ("\"vvouch.c\", line 19.5: 1506-046 (S) Syntax error."
86 1 5 19 "vvouch.c")
87 ("\"foo.c\", line 32 pos 1; (E) syntax error; unexpected symbol: \"lossage\""
88 1 1 32 "foo.c")
89 ("\"foo.adb\", line 2(11): warning: file name does not match ..."
90 1 11 2 "foo.adb")
91 ("\"src/swapping.c\", line 30.34: 1506-342 (W) \"/*\" detected in comment."
92 1 34 30 "src/swapping.c")
93 ;; cucumber
94 ("Scenario: undefined step # features/cucumber.feature:3"
95 29 nil 3 "features/cucumber.feature")
96 (" /home/gusev/.rvm/foo/bar.rb:500:in `_wrap_assertion'"
97 1 nil 500 "/home/gusev/.rvm/foo/bar.rb")
98 ;; edg-1 edg-2
99 ("build/intel/debug/../../../struct.cpp(42): error: identifier \"foo\" is undefined"
100 1 nil 42 "build/intel/debug/../../../struct.cpp")
101 ("build/intel/debug/struct.cpp(44): warning #1011: missing return statement at end of"
102 1 nil 44 "build/intel/debug/struct.cpp")
103 ("build/intel/debug/iptr.h(302): remark #981: operands are evaluated in unspecified order"
104 1 nil 302 "build/intel/debug/iptr.h")
105 (" detected during ... at line 62 of \"build/intel/debug/../../../trace.h\""
106 31 nil 62 "build/intel/debug/../../../trace.h")
107 ;; epc
108 ("Error 24 at (2:progran.f90) : syntax error"
109 1 nil 2 "progran.f90")
110 ;; ftnchek
111 (" Dummy arg W in module SUBA line 8 file arrayclash.f is array"
112 32 nil 8 "arrayclash.f")
113 (" L4 used at line 55 file test/assign.f; never set"
114 16 nil 55 "test/assign.f")
115 ("Warning near line 10 file arrayclash.f: Module contains no executable"
116 1 nil 10 "arrayclash.f")
117 ("Nonportable usage near line 31 col 9 file assign.f: mixed default and explicit"
118 24 9 31 "assign.f")
119 ;; iar
120 ("\"foo.c\",3 Error[32]: Error message"
121 1 nil 3 "foo.c")
122 ("\"foo.c\",3 Warning[32]: Error message"
123 1 nil 3 "foo.c")
124 ;; ibm
125 ("foo.c(2:0) : informational EDC0804: Function foo is not referenced."
126 1 0 2 "foo.c")
127 ("foo.c(3:8) : warning EDC0833: Implicit return statement encountered."
128 1 8 3 "foo.c")
129 ("foo.c(5:5) : error EDC0350: Syntax error."
130 1 5 5 "foo.c")
131 ;; irix
132 ("ccom: Error: foo.c, line 2: syntax error"
133 1 nil 2 "foo.c")
134 ("cc: Severe: /src/Python-2.3.3/Modules/_curses_panel.c, line 17: Cannot find file <panel.h> ..."
135 1 nil 17 "/src/Python-2.3.3/Modules/_curses_panel.c")
136 ("cc: Info: foo.c, line 27: ..."
137 1 nil 27 "foo.c")
138 ("cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ..."
139 1 nil 2 "foo.c")
140 ("cfe: Warning 600: xfe.c: 170: Not in a conditional directive while ..."
141 1 nil 170 "xfe.c")
142 ("/usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah"
143 1 nil 1 "foo.c")
144 ("/usr/lib/cmplrs/cc/cfe: warning: foo.c: 1: blah blah"
145 1 nil 1 "foo.c")
146 ("foo bar: baz.f, line 27: ..."
147 1 nil 27 "baz.f")
148 ;; java
149 ("\tat org.foo.ComponentGateway.doGet(ComponentGateway.java:172)"
150 5 nil 172 "ComponentGateway.java")
151 ("\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:740)"
152 5 nil 740 "HttpServlet.java")
153 ("==1332== at 0x4040743C: System::getErrorString() (../src/Lib/System.cpp:217)"
154 13 nil 217 "../src/Lib/System.cpp")
155 ("==1332== by 0x8008621: main (vtest.c:180)"
156 13 nil 180 "vtest.c")
157 ;; jikes-file jikes-line
158 ("Found 2 semantic errors compiling \"../javax/swing/BorderFactory.java\":"
159 1 nil nil "../javax/swing/BorderFactory.java")
160 ("Issued 1 semantic warning compiling \"java/awt/Toolkit.java\":"
161 1 nil nil "java/awt/Toolkit.java")
162 ;; gcc-include
163 ("In file included from /usr/include/c++/3.3/backward/warn.h:4,"
164 1 nil 4 "/usr/include/c++/3.3/backward/warn.h")
165 (" from /usr/include/c++/3.3/backward/iostream.h:31:0,"
166 1 0 31 "/usr/include/c++/3.3/backward/iostream.h")
167 (" from test_clt.cc:1:"
168 1 nil 1 "test_clt.cc")
169 ;; gnu
170 ("foo.c:8: message" 1 nil 8 "foo.c")
171 ("../foo.c:8: W: message" 1 nil 8 "../foo.c")
172 ("/tmp/foo.c:8:warning message" 1 nil 8 "/tmp/foo.c")
173 ("foo/bar.py:8: FutureWarning message" 1 nil 8 "foo/bar.py")
174 ("foo.py:8: RuntimeWarning message" 1 nil 8 "foo.py")
175 ("foo.c:8:I: message" 1 nil 8 "foo.c")
176 ("foo.c:8.23: note: message" 1 23 8 "foo.c")
177 ("foo.c:8.23: info: message" 1 23 8 "foo.c")
178 ("foo.c:8:23:information: message" 1 23 8 "foo.c")
179 ("foo.c:8.23-45: Informational: message" 1 (23 . 46) (8 . nil) "foo.c")
180 ("foo.c:8-23: message" 1 nil (8 . 23) "foo.c")
181 ;; The next one is not in the GNU standards AFAICS.
182 ;; Here we seem to interpret it as LINE1-LINE2.COL2.
183 ("foo.c:8-45.3: message" 1 (nil . 4) (8 . 45) "foo.c")
184 ("foo.c:8.23-9.1: message" 1 (23 . 2) (8 . 9) "foo.c")
185 ("jade:dbcommon.dsl:133:17:E: missing argument for function call"
186 1 17 133 "dbcommon.dsl")
187 ("G:/cygwin/dev/build-myproj.xml:54: Compiler Adapter 'javac' can't be found."
188 1 nil 54 "G:/cygwin/dev/build-myproj.xml")
189 ("file:G:/cygwin/dev/build-myproj.xml:54: Compiler Adapter 'javac' can't be found."
190 1 nil 54 "G:/cygwin/dev/build-myproj.xml")
191 ("{standard input}:27041: Warning: end of file not at end of a line; newline inserted"
192 1 nil 27041 "{standard input}")
193 ;; lcc
194 ("E, file.cc(35,52) Illegal operation on pointers" 1 52 35 "file.cc")
195 ("W, file.cc(36,52) blah blah" 1 52 36 "file.cc")
196 ;; makepp
197 ("makepp: Scanning `/foo/bar.c'" 19 nil nil "/foo/bar.c")
198 ("makepp: warning: bla bla `/foo/bar.c' and `/foo/bar.h'" 27 nil nil "/foo/bar.c")
199 ("makepp: bla bla `/foo/Makeppfile:12' bla" 18 nil 12 "/foo/Makeppfile")
200 ("makepp: bla bla `/foo/bar.c' and `/foo/bar.h'" 35 nil nil "/foo/bar.h")
201 ;; maven
202 ("FooBar.java:[111,53] no interface expected here"
203 1 53 111 "FooBar.java")
204 (" [ERROR] /Users/cinsk/hello.java:[651,96] ';' expected"
205 15 96 651 "/Users/cinsk/hello.java") ;Bug#11517.
206 ;; mips-1 mips-2
207 ("TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomo.c due to truncation"
208 11 nil 255 "solomon.c")
209 ("TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomo.c due to truncation"
210 70 nil 93 "solomo.c")
211 ("name defined but never used: LinInt in cmap_calc.c(199)"
212 40 nil 199 "cmap_calc.c")
213 ;; msft
214 ("keyboard handler.c(537) : warning C4005: 'min' : macro redefinition"
215 1 nil 537 "keyboard handler.c")
216 ("d:\\tmp\\test.c(23) : error C2143: syntax error : missing ';' before 'if'"
217 1 nil 23 "d:\\tmp\\test.c")
218 ("d:\\tmp\\test.c(1145) : see declaration of 'nsRefPtr'"
219 1 nil 1145 "d:\\tmp\\test.c")
220 ("1>test_main.cpp(29): error C2144: syntax error : 'int' should be preceded by ';'"
221 3 nil 29 "test_main.cpp")
222 ("1>test_main.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
223 3 nil 29 "test_main.cpp")
224 ;; watcom
225 ("..\src\ctrl\lister.c(109): Error! E1009: Expecting ';' but found '{'"
226 1 nil 109 "..\src\ctrl\lister.c")
227 ("..\src\ctrl\lister.c(120): Warning! W201: Unreachable code"
228 1 nil 120 "..\src\ctrl\lister.c")
229 ;; oracle
230 ("Semantic error at line 528, column 5, file erosacqdb.pc:"
231 1 5 528 "erosacqdb.pc")
232 ("Error at line 41, column 10 in file /usr/src/sb/ODBI_BHP.hpp"
233 1 10 41 "/usr/src/sb/ODBI_BHP.hpp")
234 ("PCC-02150: error at line 49, column 27 in file /usr/src/sb/ODBI_dxfgh.pc"
235 1 27 49 "/usr/src/sb/ODBI_dxfgh.pc")
236 ("PCC-00003: invalid SQL Identifier at column name in line 12 of file /usr/src/sb/ODBI_BHP.hpp"
237 1 nil 12 "/usr/src/sb/ODBI_BHP.hpp")
238 ("PCC-00004: mismatched IF/ELSE/ENDIF block at line 27 in file /usr/src/sb/ODBI_BHP.hpp"
239 1 nil 27 "/usr/src/sb/ODBI_BHP.hpp")
240 ("PCC-02151: line 21 column 40 file /usr/src/sb/ODBI_BHP.hpp:"
241 1 40 21 "/usr/src/sb/ODBI_BHP.hpp")
242 ;; perl
243 ("syntax error at automake line 922, near \"':'\""
244 14 nil 922 "automake")
245 ("Died at test.pl line 27."
246 6 nil 27 "test.pl")
247 ("store::odrecall('File_A', 'x2') called at store.pm line 90"
248 40 nil 90 "store.pm")
249 ("\t(in cleanup) something bad at foo.pl line 3 during global destruction."
250 29 nil 3 "foo.pl")
251 ("GLib-GObject-WARNING **: /build/buildd/glib2.0-2.14.5/gobject/gsignal.c:1741: instance `0x8206790' has no handler with id `1234' at t-compilation-perl-gtk.pl line 3."
252 130 nil 3 "t-compilation-perl-gtk.pl")
253 ;; php
254 ("Parse error: parse error, unexpected $ in main.php on line 59"
255 1 nil 59 "main.php")
256 ("Fatal error: Call to undefined function: mysql_pconnect() in db.inc on line 66"
257 1 nil 66 "db.inc")
258 ;; ruby
259 ("plain-exception.rb:7:in `fun': unhandled exception"
260 1 nil 7 "plain-exception.rb")
261 ("\tfrom plain-exception.rb:3:in `proxy'" 2 nil 3 "plain-exception.rb")
262 ("\tfrom plain-exception.rb:12" 2 nil 12 "plain-exception.rb")
263 ;; ruby-Test::Unit
264 ;; FIXME
265 (" [examples/test-unit.rb:28:in `here_is_a_deep_assert'"
266 5 nil 28 "examples/test-unit.rb")
267 (" examples/test-unit.rb:19:in `test_a_deep_assert']:"
268 6 nil 19 "examples/test-unit.rb")
269 ("examples/test-unit.rb:10:in `test_assert_raise'"
270 1 nil 10 "examples/test-unit.rb")
271 ;; rxp
272 ("Error: Mismatched end tag: expected </geroup>, got </group>\nin unnamed entity at line 71 char 8 of file:///home/reto/test/group.xml"
273 1 8 71 "/home/reto/test/group.xml")
274 ("Warning: Start tag for undeclared element geroup\nin unnamed entity at line 4 char 8 of file:///home/reto/test/group.xml"
275 1 8 4 "/home/reto/test/group.xml")
276 ;; sparc-pascal-file sparc-pascal-line sparc-pascal-example
277 ("Thu May 14 10:46:12 1992 mom3.p:"
278 1 nil nil "mom3.p")
279 ;; sun
280 ("cc-1020 CC: REMARK File = CUI_App.h, Line = 735"
281 13 nil 735 "CUI_App.h")
282 ("cc-1070 cc: WARNING File = linkl.c, Line = 38"
283 13 nil 38 "linkl.c")
284 ("cf90-113 f90comp: ERROR NSE, File = Hoved.f90, Line = 16, Column = 3"
285 18 3 16 "Hoved.f90")
286 ;; sun-ada
287 ("/home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: \",\" inserted"
288 1 6 361 "/home3/xdhar/rcds_rc/main.a")
289 ;; 4bsd
290 ("/usr/src/foo/foo.c(8): warning: w may be used before set"
291 1 nil 8 "/usr/src/foo/foo.c")
292 ("/usr/src/foo/foo.c(9): error: w is used before set"
293 1 nil 9 "/usr/src/foo/foo.c")
294 ("strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8)"
295 44 nil 8 "/usr/src/foo/foo.c")
296 ("bloofle defined( /users/wolfgang/foo.c(4) ), but never used"
297 18 nil 4 "/users/wolfgang/foo.c")
298 ;; perl--Pod::Checker
299 ;; FIXME
300 ;; *** ERROR: Spurious text after =cut at line 193 in file foo.pm
301 ;; *** ERROR: =over on line 37 without closing =back at line EOF in file bar.pm
302 ;; *** ERROR: =over on line 1 without closing =back (at head1) at line 3 in file x.pod
303 ;; perl--Test
304 ("# Failed test 1 in foo.t at line 6"
305 1 nil 6 "foo.t")
306 ;; perl--Test::Harness
307 ("NOK 1# Test 1 got: \"1234\" (t/foo.t at line 46)"
308 1 nil 46 "t/foo.t")
309 ;; weblint
310 ("index.html (13:1) Unknown element <fdjsk>"
311 1 1 13 "index.html"))
312 "List of tests for `compilation-error-regexp-alist'.
313 Each element has the form (STR POS COLUMN LINE FILENAME), where
314 STR is an error string, POS is the position of the error in STR,
315 COLUMN and LINE are the reported column and line numbers (or nil)
316 for that error, and FILENAME is the reported filename.
318 LINE can also be of the form (LINE . END-LINE) meaning a range of
319 lines. COLUMN can also be of the form (COLUMN . END-COLUMN)
320 meaning a range of columns starting on LINE and ending on
321 END-LINE, if that matched.")
323 (defun compile--test-error-line (test)
324 (erase-buffer)
325 (setq compilation-locs (make-hash-table))
326 (insert (car test))
327 (compilation-parse-errors (point-min) (point-max))
328 (let ((msg (get-text-property (nth 1 test) 'compilation-message)))
329 (when msg
330 (let ((loc (compilation--message->loc msg))
331 (col (nth 2 test))
332 (line (nth 3 test))
333 (file (nth 4 test))
334 end-col end-line)
335 (if (consp col)
336 (setq end-col (cdr col) col (car col)))
337 (if (consp line)
338 (setq end-line (cdr line) line (car line)))
339 (and (equal (compilation--loc->col loc) col)
340 (equal (compilation--loc->line loc) line)
341 (equal (caar (compilation--loc->file-struct loc)) file)
342 (or (null end-col)
343 (equal (car (cadr (nth 2 (compilation--loc->file-struct loc))))
344 end-col))
345 (equal (car (nth 2 (compilation--loc->file-struct loc)))
346 (or end-line line)))))))
348 (ert-deftest compile-test-error-regexps ()
349 "Test the `compilation-error-regexp-alist' regexps.
350 The test data is in `compile-tests--test-regexps-data'."
351 (with-temp-buffer
352 (font-lock-mode -1)
353 (dolist (test compile-tests--test-regexps-data)
354 (should (compile--test-error-line test)))))
356 ;;; compile-tests.el ends here.