From 6713b5dbbc4b3bbfa2022538501c7f8104f1e5fd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 18 Dec 2021 15:54:38 -0800 Subject: cmd/doc: don't log on constraint type elements Fixes #50256 Change-Id: I2327a0b28f8173c801ed2946bec8083967667027 Reviewed-on: https://go-review.googlesource.com/c/go/+/373314 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Robert Findley --- src/cmd/doc/doc_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/cmd/doc/doc_test.go') diff --git a/src/cmd/doc/doc_test.go b/src/cmd/doc/doc_test.go index af7793133e..0ff9edcde3 100644 --- a/src/cmd/doc/doc_test.go +++ b/src/cmd/doc/doc_test.go @@ -7,6 +7,7 @@ package main import ( "bytes" "flag" + "log" "os" "path/filepath" "regexp" @@ -125,6 +126,9 @@ var tests = []test{ `func MultiLineFunc\(x interface{ ... }\) \(r struct{ ... }\)`, // Multi line function. `var LongLine = newLongLine\(("someArgument[1-4]", ){4}...\)`, // Long list of arguments. `type T1 = T2`, // Type alias + `type SimpleConstraint interface{ ... }`, + `type TildeConstraint interface{ ... }`, + `type StructConstraint interface{ ... }`, }, []string{ `const internalConstant = 2`, // No internal constants. @@ -199,6 +203,9 @@ var tests = []test{ `Comment about exported method`, `type T1 = T2`, `type T2 int`, + `type SimpleConstraint interface {`, + `type TildeConstraint interface {`, + `type StructConstraint interface {`, }, []string{ `constThree`, @@ -822,13 +829,19 @@ var tests = []test{ func TestDoc(t *testing.T) { maybeSkip(t) + defer log.SetOutput(log.Writer()) for _, test := range tests { var b bytes.Buffer var flagSet flag.FlagSet + var logbuf bytes.Buffer + log.SetOutput(&logbuf) err := do(&b, &flagSet, test.args) if err != nil { t.Fatalf("%s %v: %s\n", test.name, test.args, err) } + if logbuf.Len() > 0 { + t.Errorf("%s %v: unexpected log messages:\n%s", test.name, test.args, logbuf.Bytes()) + } output := b.Bytes() failed := false for j, yes := range test.yes { -- cgit v1.3-5-g9baa