Skip to content

Ignore directories ending in .go during source discovery - #204

Open
2836048681 wants to merge 1 commit into
cweill:developfrom
2836048681:fix/46-go-suffix-directories
Open

2836048681 wants to merge 1 commit into
cweill:developfrom
2836048681:fix/46-go-suffix-directories

Conversation

@2836048681

Copy link
Copy Markdown

Passing a directory such as /path/to/foo.go to gotests can fail with other file parser.ParseFile: read .../foo.go: is a directory. Although the input path itself is recognized as a directory, source discovery from its parent includes every *.go glob match, including directories. The same error occurs when a source file has a neighboring directory ending in .go.

Check glob matches with os.Stat and skip directories before passing paths to the parser. Add regression tests for source discovery, directory input, and explicit source input with a neighboring .go directory.

Validation:

  • New regression tests fail on the original code with directories returned as source paths and parser is a directory errors.
  • go test ./... -count=1 passes across all packages (Go 1.27.4).
  • CLI: gotests -all -w /path/to/foo.go successfully generates TestAdd; compiling and running the generated test passes.
  • git diff --check HEAD^ HEAD passes.

Fixes #46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when current directory name ends with .go

1 participant