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