aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPhilipp Stephani2016-12-10 21:36:15 +0100
committerPhilipp Stephani2016-12-11 16:34:32 +0100
commitc0cfe9bc143686cd97d431831f47787753a95a42 (patch)
tree704f03ed3639e14266e1e33b396e77650eb99f81 /test
parent595a4d6bfd5aad79fb3ab681ae06f0739a4a5701 (diff)
downloademacs-c0cfe9bc143686cd97d431831f47787753a95a42.tar.gz
emacs-c0cfe9bc143686cd97d431831f47787753a95a42.zip
Clean up compile-tests.el
Switch to lexical binding. Make checkdoc happy. * test/lisp/progmodes/compile-tests.el (compile--test-error-line) (compile-test-error-regexps): Instead of checking a single Boolean value, use `should' for each attribute of the message to be compared. (compile-tests--test-regexps-data): Document sixth list element TYPE.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/compile-tests.el68
1 files changed, 37 insertions, 31 deletions
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index 265baf2085a..631174fa008 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -1,4 +1,4 @@
1;;; compile-tests.el --- Test suite for compile.el. 1;;; compile-tests.el --- Test suite for compile.el. -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2011-2016 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
4 4
@@ -21,6 +21,10 @@
21;; You should have received a copy of the GNU General Public License 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/>. 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 23
24;;; Commentary:
25
26;; Unit tests for lisp/progmodes/compile.el.
27
24;;; Code: 28;;; Code:
25 29
26(require 'ert) 30(require 'ert)
@@ -323,15 +327,18 @@
323 ("index.html (13:1) Unknown element <fdjsk>" 327 ("index.html (13:1) Unknown element <fdjsk>"
324 1 1 13 "index.html")) 328 1 1 13 "index.html"))
325 "List of tests for `compilation-error-regexp-alist'. 329 "List of tests for `compilation-error-regexp-alist'.
326Each element has the form (STR POS COLUMN LINE FILENAME), where 330Each element has the form (STR POS COLUMN LINE FILENAME [TYPE]),
327STR is an error string, POS is the position of the error in STR, 331where STR is an error string, POS is the position of the error in
328COLUMN and LINE are the reported column and line numbers (or nil) 332STR, COLUMN and LINE are the reported column and line numbers (or
329for that error, and FILENAME is the reported filename. 333nil) for that error, FILENAME is the reported filename, and TYPE
334is 0 for an information message, 1 for a warning, and 2 for an
335error.
330 336
331LINE can also be of the form (LINE . END-LINE) meaning a range of 337LINE can also be of the form (LINE . END-LINE) meaning a range of
332lines. COLUMN can also be of the form (COLUMN . END-COLUMN) 338lines. COLUMN can also be of the form (COLUMN . END-COLUMN)
333meaning a range of columns starting on LINE and ending on 339meaning a range of columns starting on LINE and ending on
334END-LINE, if that matched.") 340END-LINE, if that matched. TYPE can be left out, in which case
341any message type is accepted.")
335 342
336(defun compile--test-error-line (test) 343(defun compile--test-error-line (test)
337 (erase-buffer) 344 (erase-buffer)
@@ -339,35 +346,34 @@ END-LINE, if that matched.")
339 (insert (car test)) 346 (insert (car test))
340 (compilation-parse-errors (point-min) (point-max)) 347 (compilation-parse-errors (point-min) (point-max))
341 (let ((msg (get-text-property (nth 1 test) 'compilation-message))) 348 (let ((msg (get-text-property (nth 1 test) 'compilation-message)))
342 (when msg 349 (should msg)
343 (let ((loc (compilation--message->loc msg)) 350 (let ((loc (compilation--message->loc msg))
344 (col (nth 2 test)) 351 (col (nth 2 test))
345 (line (nth 3 test)) 352 (line (nth 3 test))
346 (file (nth 4 test)) 353 (file (nth 4 test))
347 (type (nth 5 test)) 354 (type (nth 5 test))
348 end-col end-line) 355 end-col end-line)
349 (if (consp col) 356 (if (consp col)
350 (setq end-col (cdr col) col (car col))) 357 (setq end-col (cdr col) col (car col)))
351 (if (consp line) 358 (if (consp line)
352 (setq end-line (cdr line) line (car line))) 359 (setq end-line (cdr line) line (car line)))
353 (and (equal (compilation--loc->col loc) col) 360 (should (equal (compilation--loc->col loc) col))
354 (equal (compilation--loc->line loc) line) 361 (should (equal (compilation--loc->line loc) line))
355 (or (not file) 362 (when file
356 (equal (caar (compilation--loc->file-struct loc)) file)) 363 (should (equal (caar (compilation--loc->file-struct loc)) file)))
357 (or (null end-col) 364 (when end-col
358 (equal (car (cadr (nth 2 (compilation--loc->file-struct loc)))) 365 (should (equal (car (cadr (nth 2 (compilation--loc->file-struct loc))))
359 end-col)) 366 end-col)))
360 (equal (car (nth 2 (compilation--loc->file-struct loc))) 367 (should (equal (car (nth 2 (compilation--loc->file-struct loc)))
361 (or end-line line)) 368 (or end-line line)))
362 (or (null type) 369 (when type
363 (equal type (compilation--message->type msg)))))))) 370 (should (equal type (compilation--message->type msg)))))))
364 371
365(ert-deftest compile-test-error-regexps () 372(ert-deftest compile-test-error-regexps ()
366 "Test the `compilation-error-regexp-alist' regexps. 373 "Test the `compilation-error-regexp-alist' regexps.
367The test data is in `compile-tests--test-regexps-data'." 374The test data is in `compile-tests--test-regexps-data'."
368 (with-temp-buffer 375 (with-temp-buffer
369 (font-lock-mode -1) 376 (font-lock-mode -1)
370 (dolist (test compile-tests--test-regexps-data) 377 (mapc #'compile--test-error-line compile-tests--test-regexps-data)))
371 (should (compile--test-error-line test)))))
372 378
373;;; compile-tests.el ends here. 379;;; compile-tests.el ends here