all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Cleaning up compile-tests.el
@ 2016-12-11  9:01 Philipp Stephani
  2016-12-11 15:29 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Stephani @ 2016-12-11  9:01 UTC (permalink / raw)
  To: Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 70 bytes --]

Hi,

attached is a small patch to clean up compile-tests.el slightly.

[-- Attachment #1.2: Type: text/html, Size: 115 bytes --]

[-- Attachment #2: 0001-Clean-up-compile-tests.el.txt --]
[-- Type: text/plain, Size: 4940 bytes --]

From dc62ea38e36b5de47893a60a76d66b7a79bf6437 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 10 Dec 2016 21:36:15 +0100
Subject: [PATCH 1/2] 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.
---
 test/lisp/progmodes/compile-tests.el | 68 ++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 31 deletions(-)

diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index 265baf2..631174f 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -1,4 +1,4 @@
-;;; compile-tests.el --- Test suite for compile.el.
+;;; compile-tests.el --- Test suite for compile.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
 
@@ -21,6 +21,10 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
+;;; Commentary:
+
+;; Unit tests for lisp/progmodes/compile.el.
+
 ;;; Code:
 
 (require 'ert)
@@ -323,15 +327,18 @@ compile-tests--test-regexps-data
     ("index.html (13:1) Unknown element <fdjsk>"
      1 1 13 "index.html"))
   "List of tests for `compilation-error-regexp-alist'.
-Each element has the form (STR POS COLUMN LINE FILENAME), where
-STR is an error string, POS is the position of the error in STR,
-COLUMN and LINE are the reported column and line numbers (or nil)
-for that error, and FILENAME is the reported filename.
+Each element has the form (STR POS COLUMN LINE FILENAME [TYPE]),
+where STR is an error string, POS is the position of the error in
+STR, COLUMN and LINE are the reported column and line numbers (or
+nil) for that error, FILENAME is the reported filename, and TYPE
+is 0 for an information message, 1 for a warning, and 2 for an
+error.
 
 LINE can also be of the form (LINE . END-LINE) meaning a range of
 lines.  COLUMN can also be of the form (COLUMN . END-COLUMN)
 meaning a range of columns starting on LINE and ending on
-END-LINE, if that matched.")
+END-LINE, if that matched.  TYPE can be left out, in which case
+any message type is accepted.")
 
 (defun compile--test-error-line (test)
   (erase-buffer)
@@ -339,35 +346,34 @@ compile--test-error-line
   (insert (car test))
   (compilation-parse-errors (point-min) (point-max))
   (let ((msg (get-text-property (nth 1 test) 'compilation-message)))
-    (when msg
-      (let ((loc (compilation--message->loc msg))
-	    (col  (nth 2 test))
-	    (line (nth 3 test))
-	    (file (nth 4 test))
-            (type (nth 5 test))
-	    end-col end-line)
-	(if (consp col)
-	    (setq end-col (cdr col) col (car col)))
-	(if (consp line)
-	    (setq end-line (cdr line) line (car line)))
-	(and (equal (compilation--loc->col loc) col)
-	     (equal (compilation--loc->line loc) line)
-             (or (not file)
-                 (equal (caar (compilation--loc->file-struct loc)) file))
-	     (or (null end-col)
-	     	 (equal (car (cadr (nth 2 (compilation--loc->file-struct loc))))
-	     		end-col))
-	     (equal (car (nth 2 (compilation--loc->file-struct loc)))
-                    (or end-line line))
-             (or (null type)
-                 (equal type (compilation--message->type msg))))))))
+    (should msg)
+    (let ((loc (compilation--message->loc msg))
+          (col  (nth 2 test))
+          (line (nth 3 test))
+          (file (nth 4 test))
+          (type (nth 5 test))
+          end-col end-line)
+      (if (consp col)
+          (setq end-col (cdr col) col (car col)))
+      (if (consp line)
+          (setq end-line (cdr line) line (car line)))
+      (should (equal (compilation--loc->col loc) col))
+      (should (equal (compilation--loc->line loc) line))
+      (when file
+        (should (equal (caar (compilation--loc->file-struct loc)) file)))
+      (when end-col
+        (should (equal (car (cadr (nth 2 (compilation--loc->file-struct loc))))
+                       end-col)))
+      (should (equal (car (nth 2 (compilation--loc->file-struct loc)))
+                     (or end-line line)))
+      (when type
+        (should (equal type (compilation--message->type msg)))))))
 
 (ert-deftest compile-test-error-regexps ()
   "Test the `compilation-error-regexp-alist' regexps.
 The test data is in `compile-tests--test-regexps-data'."
   (with-temp-buffer
     (font-lock-mode -1)
-    (dolist (test compile-tests--test-regexps-data)
-      (should (compile--test-error-line test)))))
+    (mapc #'compile--test-error-line compile-tests--test-regexps-data)))
 
-;;; compile-tests.el ends here.
+;;; compile-tests.el ends here
-- 
2.8.0.rc3.226.g39d4020


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Cleaning up compile-tests.el
  2016-12-11  9:01 Cleaning up compile-tests.el Philipp Stephani
@ 2016-12-11 15:29 ` Eli Zaretskii
  2016-12-11 15:36   ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2016-12-11 15:29 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 11 Dec 2016 09:01:18 +0000
> 
> attached is a small patch to clean up compile-tests.el slightly.

LGTM, thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cleaning up compile-tests.el
  2016-12-11 15:29 ` Eli Zaretskii
@ 2016-12-11 15:36   ` Philipp Stephani
  0 siblings, 0 replies; 3+ messages in thread
From: Philipp Stephani @ 2016-12-11 15:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 279 bytes --]

Pushed to master.

Eli Zaretskii <eliz@gnu.org> schrieb am So., 11. Dez. 2016 um 16:29 Uhr:

> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Sun, 11 Dec 2016 09:01:18 +0000
> >
> > attached is a small patch to clean up compile-tests.el slightly.
>
> LGTM, thanks.
>

[-- Attachment #2: Type: text/html, Size: 734 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-11 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-11  9:01 Cleaning up compile-tests.el Philipp Stephani
2016-12-11 15:29 ` Eli Zaretskii
2016-12-11 15:36   ` Philipp Stephani

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.