]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/testdir: update errors when filepaths include 'C:\'
authorthepudds <thepudds1460@gmail.com>
Fri, 18 Aug 2023 19:24:39 +0000 (15:24 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 20 Nov 2024 13:07:03 +0000 (13:07 +0000)
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>
src/cmd/internal/testdir/testdir_test.go

index 8ebf6eafde541e47369dc64ddf2a4a8a04158e1f..f716e1b697c48df7bd415bce8e5216eb051405c7 100644 (file)
@@ -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, ":")