Skip to content

Commit

Permalink
godoc: re-add test for ignoring //line comments in source code
Browse files Browse the repository at this point in the history
The original CL 84050044 added a test case, and it happened to be
in between various CLI test cases. CLI support was removed from
x/tools/cmd/godoc in CL 141397, as part of golang/go#25443.
Re-add a test case for this behavior to prevent regressions.

Updates golang/go#32092
Updates golang/go#25443
Updates golang/go#5247

Change-Id: I0cea74cfe40d120e398a9005676134c5bad6136c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177737
Reviewed-by: Robert Griesemer <[email protected]>
  • Loading branch information
dmitshur committed May 28, 2019
1 parent d238219 commit 09281b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion godoc/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *Corpus) parseFile(fset *token.FileSet, filename string, mode parser.Mod
}

// Temporary ad-hoc fix for issue 5247.
// TODO(gri) Remove this in favor of a better fix, eventually (see issue 7702).
// TODO(gri,dmitshur) Remove this in favor of a better fix, eventually (see issue 32092).
replaceLinePrefixCommentsWithBlankLine(src)

return parser.ParseFile(fset, filename, src, mode)
Expand Down
21 changes: 21 additions & 0 deletions godoc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,24 @@ package main`}))
t.Error("pInfo.FSet = nil; want non-nil.")
}
}

func TestIssue5247(t *testing.T) {
const packagePath = "example.com/p"
c := NewCorpus(mapfs.New(map[string]string{
"src/" + packagePath + "/p.go": `package p
//line notgen.go:3
// F doc //line 1 should appear
// line 2 should appear
func F()
//line foo.go:100`})) // No newline at end to check corner cases.

srv := &handlerServer{
p: &Presentation{Corpus: c},
c: c,
}
pInfo := srv.GetPageInfo("/src/"+packagePath, packagePath, 0, "linux", "amd64")
if got, want := pInfo.PDoc.Funcs[0].Doc, "F doc //line 1 should appear\nline 2 should appear\n"; got != want {
t.Errorf("pInfo.PDoc.Funcs[0].Doc = %q; want %q", got, want)
}
}

0 comments on commit 09281b5

Please sign in to comment.