From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32051@debbugs.gnu.org, Dan Harms <Dan.Harms@xrtrading.com>
Subject: bug#32051: 26.1; grep-regexp-alist on windows
Date: Mon, 9 Jul 2018 17:08:29 -0400 [thread overview]
Message-ID: <CAM-tV--Z=zuFvWPPiZPGjeidrUms2mDnTD9Bk6O3PcD=2P7XRw@mail.gmail.com> (raw)
In-Reply-To: <834lhcn3v7.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
On 6 July 2018 at 04:51, Eli Zaretskii <eliz@gnu.org> wrote:
> Looks reasonable. Can we have a test for this use case, so that we
> never again regress like that?
Sure, here's a full patch with testcases.
[-- Attachment #2: v1-0001-Match-w32-paths-in-grep-sans-null-hits-Bug-32051.patch --]
[-- Type: application/octet-stream, Size: 4731 bytes --]
From 0cac6938f4fa2b453a4ed5d1cc17a082a7ecf289 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Mon, 9 Jul 2018 16:56:47 -0400
Subject: [PATCH v1] Match w32 paths in grep sans --null hits (Bug#32051)
* lisp/progmodes/grep.el (grep-regexp-alist): Add an optional part to
match paths starting with C: (other drive letters).
* test/lisp/progmodes/compile-tests.el
(compile-tests--grep-regexp-testcases)
(compile-tests--grep-regexp-tricky-testcases)
(compile-test-grep-regexps): New tests.
(compile--test-error-line): Return `compilation-message'.
---
lisp/progmodes/grep.el | 4 +++-
test/lisp/progmodes/compile-tests.el | 46 +++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index da09c90..0bfabd5 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -379,7 +379,9 @@ grep-regexp-alist
;; to handle weird file names (with colons in them) as
;; well as possible. E.g., use [1-9][0-9]* rather than
;; [0-9]+ so as to accept ":034:" in file names.
- "\\(?1:[^\n:]+?[^\n/:]\\):[\t ]*\\(?2:[1-9][0-9]*\\)[\t ]*:"
+ "\\(?1:"
+ "\\(?:[a-zA-Z]:\\)?" ; Allow "C:..." for w32.
+ "[^\n:]+?[^\n/:]\\):[\t ]*\\(?2:[1-9][0-9]*\\)[\t ]*:"
"\\)")
1 2
;; Calculate column positions (col . end-col) of first grep match on a line
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index a106030..4e2dc86 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -343,6 +343,29 @@ compile-tests--test-regexps-data
END-LINE, if that matched. TYPE can be left out, in which case
any message type is accepted.")
+(defconst compile-tests--grep-regexp-testcases
+ ;; Bug#32051.
+ '(("c:/Users/my.name/src/project\\src\\kbhit.hpp\0\ 29:#include <termios.h>"
+ 1 nil 29 "c:/Users/my.name/src/project\\src\\kbhit.hpp")
+ ("d:/gnu/emacs/branch/src/callproc.c\0\ 214:#ifdef DOS_NT"
+ 1 nil 214 "d:/gnu/emacs/branch/src/callproc.c")
+ ("/gnu/emacs/branch/src/callproc.c\0\ 214:#ifdef DOS_NT"
+ 1 nil 214 "/gnu/emacs/branch/src/callproc.c"))
+ "List of tests for `grep-regexp-list'.
+The format is the same as `compile-tests--test-regexps-data', but
+the match is expected to be the same when NUL bytes are replaced
+with colon.")
+
+(defconst compile-tests--grep-regexp-tricky-testcases
+ ;; Bug#7378.
+ '(("./x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0\0\ 42:some text"
+ 1 nil 42 "./x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0")
+ ("2011-08-31_11:57:03_1\0\ 7:Date: Wed, 31 Aug 2011 11:57:03 +0000"
+ 1 nil 7 "2011-08-31_11:57:03_1"))
+ "List of tricky tests for `grep-regexp-list'.
+Same as `compile-tests--grep-regexp-testcases', but these cases
+can only work with the NUL byte to disambiguate colons.")
+
(defun compile--test-error-line (test)
(erase-buffer)
(setq compilation-locs (make-hash-table))
@@ -370,7 +393,8 @@ compile--test-error-line
(should (equal (car (nth 2 (compilation--loc->file-struct loc)))
(or end-line line)))
(when type
- (should (equal type (compilation--message->type msg)))))))
+ (should (equal type (compilation--message->type msg)))))
+ msg))
(ert-deftest compile-test-error-regexps ()
"Test the `compilation-error-regexp-alist' regexps.
@@ -379,4 +403,24 @@ compile--test-error-line
(font-lock-mode -1)
(mapc #'compile--test-error-line compile-tests--test-regexps-data)))
+(ert-deftest compile-test-grep-regexps ()
+ "Test the `grep-regexp-alist' regexps.
+The test data is in `compile-tests--grep-regexp-testcases'."
+ (with-temp-buffer
+ (grep-mode)
+ (setq buffer-read-only nil)
+ (font-lock-mode -1)
+ (dolist (testcase compile-tests--grep-regexp-testcases)
+ (let (msg1 msg2)
+ (setq msg1 (ert-info ((format "%S" testcase) :prefix "testcase: ")
+ (compile--test-error-line testcase)))
+ ;; Make sure replacing the NUL character with a colon still matches.
+ (setf (car testcase) (replace-regexp-in-string "\0" ":" (car testcase)))
+ (setq msg2 (ert-info ((format "%S" testcase) :prefix "testcase: ")
+ (compile--test-error-line testcase)))
+ (should (equal msg1 msg2))))
+ (dolist (testcase compile-tests--grep-regexp-tricky-testcases)
+ (ert-info ((format "%S" testcase) :prefix "testcase: ")
+ (compile--test-error-line testcase)))))
+
;;; compile-tests.el ends here
--
2.6.2.windows.1
next prev parent reply other threads:[~2018-07-09 21:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 12:14 bug#32051: 26.1; grep-regexp-alist on windows Dan Harms
2018-07-04 16:26 ` Eli Zaretskii
2018-07-04 19:57 ` Noam Postavsky
2018-07-06 8:51 ` Eli Zaretskii
2018-07-09 21:08 ` Noam Postavsky [this message]
2018-07-10 15:57 ` Eli Zaretskii
2018-07-13 1:51 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM-tV--Z=zuFvWPPiZPGjeidrUms2mDnTD9Bk6O3PcD=2P7XRw@mail.gmail.com' \
--to=npostavs@gmail.com \
--cc=32051@debbugs.gnu.org \
--cc=Dan.Harms@xrtrading.com \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.