-
Notifications
You must be signed in to change notification settings - Fork 492
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
Cucumber new tag expressions syntax support #668
Cucumber new tag expressions syntax support #668
Conversation
* Updated the gem to use Cucumber::TagExpressions::Parser to support new tag expression syntax * parallel_cucumber command will calculate the scenarios to be executed based on passed tag expression string correctly now and will hence determine the scenarios to be executed per node correctly. * added few more rspec tests to test additional tag expression combinations possible with new syntax
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.
Updated
tags.concat options[:ignore_tag_pattern].to_s.split(/\s*,\s*/).map {|tag| "~#{tag}" } | ||
tags.concat options[:test_options].to_s.scan(/(?:-t|--tags) (~?@[\w,~@]+)/).flatten | ||
# Combine and generate a tag expression for given test options and ignore tag pattern. Refer here to understand how new tag expression syntax works - https://github.com/cucumber/cucumber/tree/master/tag-expressions | ||
tags = [options[:test_options]] |
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.
test_options are the raw arguments passed to cucumber, so they would be -t sometag
and not just sometag
?
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.
Yeah, I totally missed that. I am working on this one now. I have changed:
tags = [options[:test_options]]
to:
tags = options[:test_options].to_s.scan(/(?:-t|--tags) ([\w,(and|or|not) ?@]+)/).flatten
I am testing it right now.
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.
This is working for all the cases except when user passes a tag expression with parenthesis like: not (@white or @blue)
I am trying to figure out the regex for that.
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.
ok, so the following does the job and handles parenthesis in tag expression as well whether passed within or without the quotes (i.e. either -t 'not (@white and @black)'
or -t not (@white and @black)
):
tags = options[:test_options].to_s.scan(/(?:-t|--tags) ([^"]*)/).flatten.map { |tag| tag.delete("'")}
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.
All the rspec tests work fine, I did update them to include -t and --tags in all test options. I am now testing this gem for a project locally.
… Reverting version update
… the tag expression with or without parenthesis and quotes
tags.concat options[:ignore_tag_pattern].to_s.split(/\s*,\s*/).map {|tag| "~#{tag}" } | ||
tags.concat options[:test_options].to_s.scan(/(?:-t|--tags) (~?@[\w,~@]+)/).flatten | ||
# Combine and generate a tag expression for given test options and ignore tag pattern. Refer here to understand how new tag expression syntax works - https://github.com/cucumber/cucumber/tree/master/tag-expressions | ||
tags = options[:test_options].to_s.scan(/(?:-t|--tags) ([^"]*)/).flatten.map { |tag| tag.delete("'")} |
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.
yeah this gets into parsing ... need to be smarter :D
try
require 'shellwords'
tags = []
words = options[:test_options].to_s.shellsplit
words.each_with_index { |w,i| tags << words[i+1] if ["-t", "--tags"].include?(w) }
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.
Perfect! The previous approach worked too but I agree it looked very complex. shellsplit
works better in this case. I updated the PR per this suggestion. All rspec tests are passing and I ran some parallel cucumber tests using local gem and it works fine.
I also updated the tag expression in scenarios_spec.rb
as cucumber
doesn't support complex tag expressions being passed without single quotes. It only works for single tags now. For example: cucumber features/ -t @colors
will work but cucumber features/ -t @colors and not @black
won't work, it has to be cucumber features/ -t '@colors and not @black'
I guess this addresses the last issue in PR and we should be good to merge now.
…upport complex tag expressions with being passed in single quotes
… tag expression from test options
Fix for issue #667
Cucumber::TagExpressions::Parser
to support new tag expression syntaxparallel_cucumber
command will calculate the scenarios to be executed based on passed tag expression string correctly now and will hence determine the scenarios to be executed per node correctly.rspec
tests to test additional tag expression combinations possible with new syntax