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