summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2021-07-18 20:32:49 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2021-07-23 15:20:44 +0200
commitaa5437493b1ca539409495ecdc54cf420ea110b9 (patch)
treec639b6850af6d0c4b86d9e4007b455e56574b1d0 /test/lisp
parent109ca1bd00b56ba66b123b505d8c2187fded0ef7 (diff)
downloademacs-aa5437493b1ca539409495ecdc54cf420ea110b9.tar.gz
emacs-aa5437493b1ca539409495ecdc54cf420ea110b9.tar.bz2
emacs-aa5437493b1ca539409495ecdc54cf420ea110b9.zip
Off-by-one error in compilation rule end-column function (bug#49624)
* lisp/progmodes/compile.el (compilation-error-properties): When the end-column parameter of a compilation message rule (in compilation-error-regexp-alist[-alist]) is a function, treat its return value as if it were matched by the regexp, which is how it is documented to work, and how all other parameters work.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/progmodes/compile-tests.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index 0623cec5285..2a3bb3dafae 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -515,4 +515,31 @@ The test data is in `compile-tests--grep-regexp-testcases'."
(compile--test-error-line testcase))
(should (eq compilation-num-errors-found 8))))
+(ert-deftest compile-test-functions ()
+ "Test rules using functions instead of regexp group numbers."
+ (let* ((file-fun (lambda () '("my-file")))
+ (line-start-fun (lambda () 123))
+ (line-end-fun (lambda () 134))
+ (col-start-fun (lambda () 39))
+ (col-end-fun (lambda () 24))
+ (compilation-error-regexp-alist-alist
+ `((my-rule
+ ,(rx bol "My error message")
+ ,file-fun
+ (,line-start-fun . ,line-end-fun)
+ (,col-start-fun . ,col-end-fun))))
+ (compilation-error-regexp-alist '(my-rule)))
+ (with-temp-buffer
+ (font-lock-mode -1)
+ (let ((compilation-num-errors-found 0)
+ (compilation-num-warnings-found 0)
+ (compilation-num-infos-found 0))
+ (compile--test-error-line
+ '(my-rule
+ "My error message"
+ 1 (39 . 24) (123 . 134) "my-file" 2))
+ (should (eq compilation-num-errors-found 1))
+ (should (eq compilation-num-warnings-found 0))
+ (should (eq compilation-num-infos-found 0))))))
+
;;; compile-tests.el ends here