Skip to content

Commit

Permalink
Group feature tags when filtering scenarios.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed May 14, 2015
1 parent 456e567 commit e6a38f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions gherkin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ func (f *Feature) FilterMatched(filters ...string) bool {
}

// FilterMatched returns true if the set of input filters match the feature's tags.
func (s *Scenario) FilterMatched(filters ...string) bool {
return matchTags(s.Tags, filters)
func (s *Scenario) FilterMatched(f *Feature, filters ...string) bool {
t := []string{}
t = append(t, f.Tags...)
t = append(t, s.Tags...)
return matchTags(t, filters)
}

func matchTags(tags []string, filters []string) bool {
Expand Down
10 changes: 5 additions & 5 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *Runner) runFeature(f *gherkin.Feature) {

// if any scenarios match, we will run those
for _, s := range f.Scenarios {
if s.FilterMatched(c.Filters...) {
if s.FilterMatched(f, c.Filters...) {
result = true
break
}
Expand Down Expand Up @@ -209,12 +209,12 @@ func (c *Runner) runFeature(f *gherkin.Feature) {
}

func (c *Runner) runScenario(title string, f *gherkin.Feature, s *gherkin.Scenario, isExample bool) {
if !s.FilterMatched(c.Filters...) {
if !s.FilterMatched(f, c.Filters...) {
return
}

for k, fn := range c.BeforeFilters {
if s.FilterMatched(strings.Split(k, "|")...) {
if s.FilterMatched(f, strings.Split(k, "|")...) {
fn()
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func (c *Runner) runScenario(title string, f *gherkin.Feature, s *gherkin.Scenar
c.line(clrWhite, "")

for k, fn := range c.AfterFilters {
if s.FilterMatched(strings.Split(k, "|")...) {
if s.FilterMatched(f, strings.Split(k, "|")...) {
fn()
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@ func (c *Runner) runScenario(title string, f *gherkin.Feature, s *gherkin.Scenar
}

for k, fn := range c.AfterFilters {
if s.FilterMatched(strings.Split(k, "|")...) {
if s.FilterMatched(f, strings.Split(k, "|")...) {
fn()
}
}
Expand Down

0 comments on commit e6a38f0

Please sign in to comment.