Skip to content

Commit a79d6ec

Browse files
thepuddspull[bot]
authored andcommitted
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 <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 31cc614 commit a79d6ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cmd/internal/testdir/testdir_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,9 +1276,16 @@ func (test) updateErrors(out, file string) {
12761276
// Parse new errors.
12771277
errors := make(map[int]map[string]bool)
12781278
tmpRe := regexp.MustCompile(`autotmp_\d+`)
1279+
fileRe := regexp.MustCompile(`(\.go):\d+:`)
12791280
for _, errStr := range splitOutput(out, false) {
1280-
errFile, rest, ok := strings.Cut(errStr, ":")
1281-
if !ok || errFile != file {
1281+
m := fileRe.FindStringSubmatchIndex(errStr)
1282+
if len(m) != 4 {
1283+
continue
1284+
}
1285+
// The end of the file is the end of the first and only submatch.
1286+
errFile := errStr[:m[3]]
1287+
rest := errStr[m[3]+1:]
1288+
if errFile != file {
12821289
continue
12831290
}
12841291
lineStr, msg, ok := strings.Cut(rest, ":")

0 commit comments

Comments
 (0)