aboutsummaryrefslogtreecommitdiff
path: root/src/testing/example.go
diff options
context:
space:
mode:
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>2024-11-10 16:57:06 +0100
committerGopher Robot <gobot@golang.org>2024-11-13 18:37:25 +0000
commitf1add185301a55f29eac65e88caa3ae1f713e766 (patch)
treed337576e7cdef86d6a68f9a4e67882be24a52304 /src/testing/example.go
parentd311cc95dcc58becdeb0f66a5b828477ee0d83bd (diff)
downloadgo-f1add185301a55f29eac65e88caa3ae1f713e766.tar.xz
testing: replace CRLF by LF on windows before comparing to the expected output
Fixes #51269 Change-Id: I06747db18ca078c1f1bda9b7bc60006f53191f4d Reviewed-on: https://go-review.googlesource.com/c/go/+/627035 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/testing/example.go')
-rw-r--r--src/testing/example.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/testing/example.go b/src/testing/example.go
index b14477a406..c343ae2aa2 100644
--- a/src/testing/example.go
+++ b/src/testing/example.go
@@ -6,6 +6,7 @@ package testing
import (
"fmt"
+ "runtime"
"slices"
"strings"
"time"
@@ -66,6 +67,10 @@ func (eg *InternalExample) processRunResult(stdout string, timeSpent time.Durati
var fail string
got := strings.TrimSpace(stdout)
want := strings.TrimSpace(eg.Output)
+ if runtime.GOOS == "windows" {
+ got = strings.ReplaceAll(got, "\r\n", "\n")
+ want = strings.ReplaceAll(want, "\r\n", "\n")
+ }
if eg.Unordered {
if sortLines(got) != sortLines(want) && recovered == nil {
fail = fmt.Sprintf("got:\n%s\nwant (unordered):\n%s\n", stdout, eg.Output)