From: thepudds Date: Fri, 18 Aug 2023 19:24:39 +0000 (-0400) Subject: cmd/internal/testdir: update errors when filepaths include 'C:\' X-Git-Tag: go1.24rc1~204 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5d2cc5662027f6464db2781c88b4f3bb64f58136;p=gostls13.git 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 Auto-Submit: Dmitri Shuralyov Reviewed-by: Matthew Dempsky LUCI-TryBot-Result: Go LUCI Reviewed-by: Than McIntosh Reviewed-by: Dmitri Shuralyov --- diff --git a/src/cmd/internal/testdir/testdir_test.go b/src/cmd/internal/testdir/testdir_test.go index 8ebf6eafde..f716e1b697 100644 --- a/src/cmd/internal/testdir/testdir_test.go +++ b/src/cmd/internal/testdir/testdir_test.go @@ -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, ":")