Skip to content
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

Merged
merged 4 commits into from Aug 13, 2021

Conversation

luke-hill
Copy link
Contributor

@luke-hill luke-hill commented Aug 11, 2021

Update running command to pass cucumber profile as the last argument (And permit --retry flag to work).

Checklist

  • Feature branch is up-to-date with master (if not - rebase it).
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • Update Readme.md when cli options are changed

@luke-hill
Copy link
Contributor Author

@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.

*sanitized_test_files
opts[0],
*sanitized_test_files,
opts[1]
Copy link
Contributor Author

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.

Copy link
Owner

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 ?

Copy link
Contributor Author

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!

Copy link
Contributor Author

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic explanation

[given, profile_from_config].compact.join(" ")
end

opts_as_individuals = initial.scan(/\S+\s\S+/)
Copy link
Contributor Author

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.

Copy link
Owner

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

opts_as_individuals = initial.scan(/\S+\s\S+/)
desired_output = ['', '']

opts_as_individuals.each do |opt|
Copy link
Contributor Author

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

Copy link
Contributor Author

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" 

end

desired_output
Copy link
Contributor Author

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

@grosser
Copy link
Owner

grosser commented Aug 12, 2021

seems super 🐟 that only retry is special

@luke-hill
Copy link
Contributor Author

It wasn't. viva la code review

@grosser grosser merged commit 3e66485 into grosser:master Aug 13, 2021
@grosser
Copy link
Owner

grosser commented Aug 13, 2021

much simpler :D

@grosser
Copy link
Owner

grosser commented Aug 13, 2021

3.7.1

@luke-hill luke-hill deleted the bugfix/enable_cucumber_retry branch August 16, 2021 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants