diff options
| author | Noam Postavsky | 2018-07-09 16:56:47 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-07-12 21:49:50 -0400 |
| commit | 3eb4603b0d432740ff4e8deb637cca2f35cf5fee (patch) | |
| tree | 0333e7f6507ec70149cc79758198c002caeb059d | |
| parent | 5cc7c4b48a2d6eca5d14d12b1cd258bf9cabde74 (diff) | |
| download | emacs-3eb4603b0d432740ff4e8deb637cca2f35cf5fee.tar.gz emacs-3eb4603b0d432740ff4e8deb637cca2f35cf5fee.zip | |
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'.
| -rw-r--r-- | lisp/progmodes/grep.el | 4 | ||||
| -rw-r--r-- | 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 da09c900e58..0bfabd5f3fe 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -379,7 +379,9 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies | |||
| 379 | ;; to handle weird file names (with colons in them) as | 379 | ;; to handle weird file names (with colons in them) as |
| 380 | ;; well as possible. E.g., use [1-9][0-9]* rather than | 380 | ;; well as possible. E.g., use [1-9][0-9]* rather than |
| 381 | ;; [0-9]+ so as to accept ":034:" in file names. | 381 | ;; [0-9]+ so as to accept ":034:" in file names. |
| 382 | "\\(?1:[^\n:]+?[^\n/:]\\):[\t ]*\\(?2:[1-9][0-9]*\\)[\t ]*:" | 382 | "\\(?1:" |
| 383 | "\\(?:[a-zA-Z]:\\)?" ; Allow "C:..." for w32. | ||
| 384 | "[^\n:]+?[^\n/:]\\):[\t ]*\\(?2:[1-9][0-9]*\\)[\t ]*:" | ||
| 383 | "\\)") | 385 | "\\)") |
| 384 | 1 2 | 386 | 1 2 |
| 385 | ;; Calculate column positions (col . end-col) of first grep match on a line | 387 | ;; 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 a106030aea1..4e2dc86eae0 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el | |||
| @@ -343,6 +343,29 @@ 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 | 343 | END-LINE, if that matched. TYPE can be left out, in which case |
| 344 | any message type is accepted.") | 344 | any message type is accepted.") |
| 345 | 345 | ||
| 346 | (defconst compile-tests--grep-regexp-testcases | ||
| 347 | ;; Bug#32051. | ||
| 348 | '(("c:/Users/my.name/src/project\\src\\kbhit.hpp\0\ 29:#include <termios.h>" | ||
| 349 | 1 nil 29 "c:/Users/my.name/src/project\\src\\kbhit.hpp") | ||
| 350 | ("d:/gnu/emacs/branch/src/callproc.c\0\ 214:#ifdef DOS_NT" | ||
| 351 | 1 nil 214 "d:/gnu/emacs/branch/src/callproc.c") | ||
| 352 | ("/gnu/emacs/branch/src/callproc.c\0\ 214:#ifdef DOS_NT" | ||
| 353 | 1 nil 214 "/gnu/emacs/branch/src/callproc.c")) | ||
| 354 | "List of tests for `grep-regexp-list'. | ||
| 355 | The format is the same as `compile-tests--test-regexps-data', but | ||
| 356 | the match is expected to be the same when NUL bytes are replaced | ||
| 357 | with colon.") | ||
| 358 | |||
| 359 | (defconst compile-tests--grep-regexp-tricky-testcases | ||
| 360 | ;; Bug#7378. | ||
| 361 | '(("./x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0\0\ 42:some text" | ||
| 362 | 1 nil 42 "./x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0") | ||
| 363 | ("2011-08-31_11:57:03_1\0\ 7:Date: Wed, 31 Aug 2011 11:57:03 +0000" | ||
| 364 | 1 nil 7 "2011-08-31_11:57:03_1")) | ||
| 365 | "List of tricky tests for `grep-regexp-list'. | ||
| 366 | Same as `compile-tests--grep-regexp-testcases', but these cases | ||
| 367 | can only work with the NUL byte to disambiguate colons.") | ||
| 368 | |||
| 346 | (defun compile--test-error-line (test) | 369 | (defun compile--test-error-line (test) |
| 347 | (erase-buffer) | 370 | (erase-buffer) |
| 348 | (setq compilation-locs (make-hash-table)) | 371 | (setq compilation-locs (make-hash-table)) |
| @@ -370,7 +393,8 @@ any message type is accepted.") | |||
| 370 | (should (equal (car (nth 2 (compilation--loc->file-struct loc))) | 393 | (should (equal (car (nth 2 (compilation--loc->file-struct loc))) |
| 371 | (or end-line line))) | 394 | (or end-line line))) |
| 372 | (when type | 395 | (when type |
| 373 | (should (equal type (compilation--message->type msg))))))) | 396 | (should (equal type (compilation--message->type msg))))) |
| 397 | msg)) | ||
| 374 | 398 | ||
| 375 | (ert-deftest compile-test-error-regexps () | 399 | (ert-deftest compile-test-error-regexps () |
| 376 | "Test the `compilation-error-regexp-alist' regexps. | 400 | "Test the `compilation-error-regexp-alist' regexps. |
| @@ -379,4 +403,24 @@ The test data is in `compile-tests--test-regexps-data'." | |||
| 379 | (font-lock-mode -1) | 403 | (font-lock-mode -1) |
| 380 | (mapc #'compile--test-error-line compile-tests--test-regexps-data))) | 404 | (mapc #'compile--test-error-line compile-tests--test-regexps-data))) |
| 381 | 405 | ||
| 406 | (ert-deftest compile-test-grep-regexps () | ||
| 407 | "Test the `grep-regexp-alist' regexps. | ||
| 408 | The test data is in `compile-tests--grep-regexp-testcases'." | ||
| 409 | (with-temp-buffer | ||
| 410 | (grep-mode) | ||
| 411 | (setq buffer-read-only nil) | ||
| 412 | (font-lock-mode -1) | ||
| 413 | (dolist (testcase compile-tests--grep-regexp-testcases) | ||
| 414 | (let (msg1 msg2) | ||
| 415 | (setq msg1 (ert-info ((format "%S" testcase) :prefix "testcase: ") | ||
| 416 | (compile--test-error-line testcase))) | ||
| 417 | ;; Make sure replacing the NUL character with a colon still matches. | ||
| 418 | (setf (car testcase) (replace-regexp-in-string "\0" ":" (car testcase))) | ||
| 419 | (setq msg2 (ert-info ((format "%S" testcase) :prefix "testcase: ") | ||
| 420 | (compile--test-error-line testcase))) | ||
| 421 | (should (equal msg1 msg2)))) | ||
| 422 | (dolist (testcase compile-tests--grep-regexp-tricky-testcases) | ||
| 423 | (ert-info ((format "%S" testcase) :prefix "testcase: ") | ||
| 424 | (compile--test-error-line testcase))))) | ||
| 425 | |||
| 382 | ;;; compile-tests.el ends here | 426 | ;;; compile-tests.el ends here |