]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/doc: fix repeated header bug added in previous CL
authorRob Pike <r@golang.org>
Wed, 17 Oct 2018 11:32:27 +0000 (22:32 +1100)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 17 Oct 2018 12:42:41 +0000 (12:42 +0000)
One too many lines was deleted, and it would print a header multiple times.
Add a test.

Change-Id: I4906b454dbb66193d515ffacf43849ffdc2dede6
Reviewed-on: https://go-review.googlesource.com/c/142937
Reviewed-by: Ralph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/doc/doc_test.go
src/cmd/doc/pkg.go

index 80fdb5c72e2860e235bb53243879253172e1cbf5..ec3a50d87df47e2501ab090a40d79d4b54c48622 100644 (file)
@@ -733,6 +733,9 @@ func TestDoc(t *testing.T) {
                                failed = true
                        }
                }
+               if bytes.Count(output, []byte("TYPES\n")) > 1 {
+                       t.Fatalf("%s: repeating headers", test.name)
+               }
                if failed {
                        t.Logf("\n%s", output)
                }
index bb1b99853776067eeacd4edc417bef3a5a53a0c0..680f555f592759e32ac5f9a3247e4448fdb4e7b9 100644 (file)
@@ -426,6 +426,7 @@ func (pkg *Package) allDoc() {
        printHdr := func(s string) {
                if hdr != s {
                        pkg.Printf("\n%s\n\n", s)
+                       hdr = s
                }
        }