diff --git a/internal/flags/options.go b/internal/flags/options.go index eca3ce2d..f7940d2a 100644 --- a/internal/flags/options.go +++ b/internal/flags/options.go @@ -4,8 +4,6 @@ import ( "context" "io" "testing" - - "github.com/cucumber/godog/internal/models" ) // Options are suite run options @@ -67,5 +65,8 @@ type Options struct { // TestingT runs scenarios as subtests. TestingT *testing.T - Features []*models.Feature + // FeatureContents allows passing in each feature manually + // where the contents of each feature is stored as a byte slice + // in a map entry + FeatureContents map[string][]byte } diff --git a/run.go b/run.go index c29f3cbb..a28af3f0 100644 --- a/run.go +++ b/run.go @@ -227,13 +227,14 @@ func runWithOptions(suiteName string, runner runner, opt Options) int { runner.fmt = multiFmt.FormatterFunc(suiteName, output) var err error - if len(opt.Features) <= 0 { - if runner.features, err = parser.ParseFeatures(opt.Tags, opt.Paths); err != nil { - fmt.Fprintln(os.Stderr, err) - return exitOptionError - } + if len(opt.Paths) > 0 { + runner.features, err = parser.ParseFeatures(opt.Tags, opt.Paths) } else { - runner.features = opt.Features + runner.features, err = parser.ParseFromBytes(opt.Tags, opt.FeatureContents) + } + if err != nil { + fmt.Fprintln(os.Stderr, err) + return exitOptionError } runner.storage = storage.NewStorage() @@ -342,22 +343,6 @@ func (ts TestSuite) RetrieveFeatures() ([]*models.Feature, error) { return parser.ParseFeatures(opt.Tags, opt.Paths) } -// should be a map of string[]byte where the string is the path name of the feature file -// and the []byte is the bytes read from the file -func (ts TestSuite) RetrieveFeaturesFromBytes(featuresInputs map[string][]byte) ([]*models.Feature, error) { - opt := ts.Options - - if opt == nil { - var err error - opt, err = getDefaultOptions() - if err != nil { - return nil, err - } - } - - return parser.ParseFromBytes(opt.Tags, featuresInputs) -} - func getDefaultOptions() (*Options, error) { opt := &Options{} opt.Output = colors.Colored(os.Stdout)