cmd/doc: continue to search when package import fails

Keep searching for a package that is both findable and importable. The
current code would always guarantee that a package was findable but
exited if it was not importable.

Fixes #25478

Change-Id: I237b7dfafb930cae02538c4a2e4d5ce0c1058478
Reviewed-on: https://go-review.googlesource.com/114295
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Michael Fraenkel 2018-05-23 17:23:35 -04:00 committed by Rob Pike
parent f864d89ef7
commit d0d47bb94f
4 changed files with 47 additions and 10 deletions

View file

@ -26,7 +26,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
dirsInit(testdataDir)
dirsInit(testdataDir, filepath.Join(testdataDir, "nested"), filepath.Join(testdataDir, "nested", "nested"))
os.Exit(m.Run())
}
@ -510,6 +510,24 @@ var tests = []test{
"\\)\n+const", // This will appear if the const decl appears twice.
},
},
{
"non-imported: pkg.sym",
[]string{"nested.Foo"},
[]string{"Foo struct"},
nil,
},
{
"non-imported: pkg only",
[]string{"nested"},
[]string{"Foo struct"},
nil,
},
{
"non-imported: pkg sym",
[]string{"nested", "Foo"},
[]string{"Foo struct"},
nil,
},
}
func TestDoc(t *testing.T) {