Skip to content

Commit

Permalink
chore: make genstd consider test files
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Dec 10, 2024
1 parent d9f4d3a commit c6728c5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions misc/genstd/genstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Check warning on line 133 in misc/genstd/genstd.go

View check run for this annotation

Codecov / codecov/patch

misc/genstd/genstd.go#L132-L133

Added lines #L132 - L133 were not covered by tests

// skip external test files
noExt := fpath[:len(fpath)-len(ext)]
if strings.HasSuffix(noExt, "_test") && strings.HasSuffix(f.Name.Name, "_test") {
return nil
}

Check warning on line 139 in misc/genstd/genstd.go

View check run for this annotation

Codecov / codecov/patch

misc/genstd/genstd.go#L138-L139

Added lines #L138 - L139 were not covered by tests

dir := filepath.Dir(fpath)
var pkg *pkgData
// if we've already been in this directory in a previous file, it must
Expand All @@ -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.
Expand Down

0 comments on commit c6728c5

Please sign in to comment.