[dev.go2go] go/go2go: add IDs for test files

No test because the test harness doesn't support test packages.
(But probably we'll need a better test harness.)

Fixes #39839

Change-Id: I4532b1443dbdd081552ffb78477cbe5039183416
Reviewed-on: https://go-review.googlesource.com/c/go/+/239708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Ian Lance Taylor 2020-06-24 16:39:54 -07:00
parent 2dce748bd8
commit acd7923802
2 changed files with 7 additions and 7 deletions

View File

@ -95,9 +95,7 @@ func rewriteFilesInPath(importer *Importer, importPath, dir string, go2files []s
return nil, fmt.Errorf("type checking failed for %s\n%v", pkg.Name, merr)
}
if !strings.HasSuffix(pkg.Name, "_test") {
importer.record(pkgfiles, importPath, tpkg, asts)
}
importer.record(pkg.Name, pkgfiles, importPath, tpkg, asts)
rpkgs = append(rpkgs, tpkg)
tpkgs = append(tpkgs, pkgfiles)

View File

@ -296,11 +296,13 @@ func (imp *Importer) localImport(importPath, dir string) (*types.Package, error)
// record records information for a package, for use when working
// with packages that import this one.
func (imp *Importer) record(pkgfiles []namedAST, importPath string, tpkg *types.Package, asts []*ast.File) {
if importPath != "" {
imp.packages[importPath] = tpkg
func (imp *Importer) record(pkgName string, pkgfiles []namedAST, importPath string, tpkg *types.Package, asts []*ast.File) {
if !strings.HasSuffix(pkgName, "_test") {
if importPath != "" {
imp.packages[importPath] = tpkg
}
imp.imports[importPath] = imp.collectImports(asts)
}
imp.imports[importPath] = imp.collectImports(asts)
for _, nast := range pkgfiles {
imp.addIDs(nast.ast)
}