mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/testdir: update errors when filepaths include 'C:\'
Currently on Windows, commands like: go test cmd/internal/testdir -run=foo -update_errors will fail to update the errors because the parsing is currently confused by the ':' in filepaths that start with 'C:\', and wrongly thinks that ':' marks the end of the Go filename. Instead of finding the first ':', use a regexp to find what looks to be the end of the Go filename. Change-Id: I091106da55b8e9e9cf421814abf26a6f8b821af9 Reviewed-on: https://go-review.googlesource.com/c/go/+/524942 Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
5e1726b71a
commit
5d2cc56620
1 changed files with 9 additions and 2 deletions
|
|
@ -1276,9 +1276,16 @@ func (test) updateErrors(out, file string) {
|
|||
// Parse new errors.
|
||||
errors := make(map[int]map[string]bool)
|
||||
tmpRe := regexp.MustCompile(`autotmp_\d+`)
|
||||
fileRe := regexp.MustCompile(`(\.go):\d+:`)
|
||||
for _, errStr := range splitOutput(out, false) {
|
||||
errFile, rest, ok := strings.Cut(errStr, ":")
|
||||
if !ok || errFile != file {
|
||||
m := fileRe.FindStringSubmatchIndex(errStr)
|
||||
if len(m) != 4 {
|
||||
continue
|
||||
}
|
||||
// The end of the file is the end of the first and only submatch.
|
||||
errFile := errStr[:m[3]]
|
||||
rest := errStr[m[3]+1:]
|
||||
if errFile != file {
|
||||
continue
|
||||
}
|
||||
lineStr, msg, ok := strings.Cut(rest, ":")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue