-
-
Notifications
You must be signed in to change notification settings - Fork 211
Open
Description
The regular expression to find Go test errors is currently (
Line 1845 in 734d523
'(go-test . ("^\\s-+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$" 1 2)) t))) |
"^\\s-+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$"
. The problem is that this regex is very broad and matches too much:
- The
\s-+
also matches newlines (at least when using the standard syntax table). - The
[^()\t\n]+
group matches a ton of things: spaces, exotic characters, NUL bytes, ...
Combined, these two mean that e.g. a GNU-style file:line:column: message
line that follows a newline is matched incorrectly:
(with-syntax-table (standard-syntax-table)
(let ((regex "^\\s-+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$")
(line "\nfile.go:1:2: word word"))
(list
(string-match regex line)
(match-string 1 line))))
⇒ (0 "file.go:1")
Here, this incorrectly treats file.go:1
as filename and 2 as line number.
This causes issues because such lines are very common in practice, and the leading newline alone is enough to trigger go-test
matching.
I recommend restricting the go-test
pattern:
- Replace the
\s-+
by a more precise match, e.g. four spaces. - Replace the filename group by something that is likely to be an actual filename (e.g. no spaces or colons).
Metadata
Metadata
Assignees
Labels
No labels