Repository navigation
Skip _test.go files when parsing enum constants - #26
Merged
Merged
Conversation
Parse grouped every package in the directory and kept the name of whichever came last in map order. With a black-box test file (package foo_test) next to the enum, the generated file got "package foo_test" in most runs and broke the build. Constants from test files also leaked into the enum, though the generated non-test file can never reference them. Test files are now ignored. Two fixtures fed to Parse were named *_test.go and are renamed to plain .go files. Related to #11
A //go:build ignore file of another package in the enum directory still makes Parse pick the package clause at random. README does not say that _test.go files are skipped. Related to #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parsegroups every package found in the directory and keeps the name of whichever one map iteration visits last. With a black-box test file (package foo_test) next to the enum, the generated<type>_enum.gogotpackage foo_testin most runs (7 of 8 in a repro) andgo buildfailed with "found packages foo and foo_test". Constants declared in test files also leaked into the enum, though the generated file is not a test file and can never reference them.Parsenow skips_test.gofiles.TestParseSkipsTestFilescovers both an internal and an external test file. Two existing fixtures fed toParsewere named*_test.goand are renamed to plain.gofiles, assertions unchanged.If an earlier run already wrote a broken
<type>_enum.gowithpackage foo_test, delete it once before regenerating, since that file itself still declares the second package.The second commit adds two
docs/backlog/items: a//go:build ignorefile of another package in the same directory still makes the package choice random, and README does not mention that test files are skipped.Related to #11