diff --git a/misc/genstd/genstd.go b/misc/genstd/genstd.go index 3dd38214595..f3656b5c0c5 100644 --- a/misc/genstd/genstd.go +++ b/misc/genstd/genstd.go @@ -119,13 +119,25 @@ func walkStdlibs(stdlibsPath string) ([]*pkgData, error) { return nil } - // skip non-source and test files. + // skip non-source files. ext := filepath.Ext(fpath) if (ext != ".go" && ext != ".gno") || strings.HasSuffix(fpath, ".gen.go") { return nil } + fs := token.NewFileSet() + f, err := parser.ParseFile(fs, fpath, nil, parser.SkipObjectResolution) + if err != nil { + return err + } + + // skip external test files + noExt := fpath[:len(fpath)-len(ext)] + if strings.HasSuffix(noExt, "_test") && strings.HasSuffix(f.Name.Name, "_test") { + return nil + } + dir := filepath.Dir(fpath) var pkg *pkgData // if we've already been in this directory in a previous file, it must @@ -141,11 +153,6 @@ func walkStdlibs(stdlibsPath string) ([]*pkgData, error) { } else { pkg = pkgs[len(pkgs)-1] } - fs := token.NewFileSet() - f, err := parser.ParseFile(fs, fpath, nil, parser.SkipObjectResolution) - if err != nil { - return err - } if ext == ".go" { // keep track of exported function declarations.