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
Permit parallel_tests/cucumber running to allow --retry flag #827
Permit parallel_tests/cucumber running to allow --retry flag #827
Conversation
@grosser This code is very poor, but it simply highlights the issue. let me know if you're happy with the approach and I can tidy up as accordingly. It's likely I'll need some pair assistance from yourself. |
lib/parallel_tests/gherkin/runner.rb
Outdated
*sanitized_test_files | ||
opts[0], | ||
*sanitized_test_files, | ||
opts[1] |
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 line is needed in some way shape or form, because the --retry n
flag must go at the end.
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.
why can't all options go to the end ?
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.
Umm I don't know. If that's the case then this entire PR can be reworked into a 1liner. Let me get back to you!
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.
Logic explanation
lib/parallel_tests/gherkin/runner.rb
Outdated
[given, profile_from_config].compact.join(" ") | ||
end | ||
|
||
opts_as_individuals = initial.scan(/\S+\s\S+/) |
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.
we now split on each space separated opt. So here for example -o "-p foo -p bar -t @footag -t @bartag --retry 3"
would become an array of those 5 items.
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.
I think you want string.shellsplit
from require 'shellwords'
package
lib/parallel_tests/gherkin/runner.rb
Outdated
opts_as_individuals = initial.scan(/\S+\s\S+/) | ||
desired_output = ['', ''] | ||
|
||
opts_as_individuals.each do |opt| |
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.
Here we iterate over each of them, and re-assemble them back how they were, with the one exception, --retry goes into a separate array. So the above example would be turned into an array of the 4 items in position 0 and --retry 3 in position 1
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.
Note to self - This might be more desirable
2.7.3 :027 > array.each_with_index do |item, index|
2.7.3 :028 > if item.match?(/--retry \d+/)
2.7.3 :029 > @desired = array.delete_at(index)
2.7.3 :030 > end
2.7.3 :031 > end
=> ["-p foo", "-p bar", "-t @foo", "-t @bar"]
2.7.3 :032 > @desired
=> "--retry 3"
lib/parallel_tests/gherkin/runner.rb
Outdated
end | ||
|
||
desired_output |
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.
returning this array we then leave all the original items (minus the retry flag, in the original position), the retry flag then goes right to the end
seems super 🐟 that only retry is special |
…mand invocation also works!
It wasn't. viva la code review |
much simpler :D |
3.7.1 |
Update running command to pass cucumber profile as the last argument (And permit --retry flag to work).
Checklist
master
(if not - rebase it).code introduces user-observable changes.