compile-tests.el 15 KB

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