New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new option for created features with parsing from byte slices #476
Changes from 6 commits
70ae9e9
1bc8da0
6a3bb0d
bef3d7c
239dd4b
25813de
59a6d90
ae2d87c
d6371df
afa6081
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,12 @@ func runWithOptions(suiteName string, runner runner, opt Options) int { | |
runner.fmt = multiFmt.FormatterFunc(suiteName, output) | ||
|
||
var err error | ||
if runner.features, err = parser.ParseFeatures(opt.Tags, opt.Paths); err != nil { | ||
if len(opt.FeatureContents) > 0 { | ||
runner.features, err = parser.ParseFromBytes(opt.Tags, opt.FeatureContents) | ||
} else { | ||
runner.features, err = parser.ParseFeatures(opt.Tags, opt.Paths) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change logic here so that both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I'm not so sure how simple this would be. From what I can see, if someone wants to run through FeatureContents only, and they leave the Paths option blank, the current behavior will force them to use a features directory by default. Either they'll have their features already in a features directory, or they won't, in which case there could be a failure due to non-existent directory, no? I think it's maybe just simpler to say, either you can use feature contents, or features, but not both. If someone is already parsing files and passing them in, I can't imagine it's much more challenging to also include from all features as opposed to from only a few. what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, this is interesting point.
Another case when this feature could be useful would be sourcing gherkin files from a remote storage (e.g. via HTTP) or generating/templating them by code. In such situation implementing additional file preloader might be a burden. If we disable that default in case of feature contents presence it may be perceived as unexpected behavior. if len(opt.Paths) == 0 && len(opt.Features) == 0 {
inf, err := os.Stat("features")
if err == nil && inf.IsDir() {
opt.Paths = []string{"features"}
}
} If we ignore From these options I'm leaning to disabling the default as it seems less disruptive overall. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! |
||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return exitOptionError | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a slice of structs to improve clarity of data items.
Something like: