aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/help_test.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/go/help_test.go b/src/cmd/go/help_test.go
index abfc3db993..3e1d817ca5 100644
--- a/src/cmd/go/help_test.go
+++ b/src/cmd/go/help_test.go
@@ -6,6 +6,8 @@ package main_test
import (
"bytes"
+ "go/format"
+ diffpkg "internal/diff"
"os"
"testing"
@@ -23,11 +25,17 @@ func TestDocsUpToDate(t *testing.T) {
buf := new(bytes.Buffer)
// Match the command in mkalldocs.sh that generates alldocs.go.
help.Help(buf, []string{"documentation"})
- data, err := os.ReadFile("alldocs.go")
+ internal := buf.Bytes()
+ internal, err := format.Source(internal)
+ if err != nil {
+ t.Fatalf("gofmt docs: %v", err)
+ }
+ alldocs, err := os.ReadFile("alldocs.go")
if err != nil {
t.Fatalf("error reading alldocs.go: %v", err)
}
- if !bytes.Equal(data, buf.Bytes()) {
- t.Errorf("alldocs.go is not up to date; run mkalldocs.sh to regenerate it")
+ if !bytes.Equal(internal, alldocs) {
+ t.Errorf("alldocs.go is not up to date; run mkalldocs.sh to regenerate it\n%s",
+ diffpkg.Diff("go help documentation | gofmt", internal, "alldocs.go", alldocs))
}
}