-
Notifications
You must be signed in to change notification settings - Fork 28
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
Pass thru test-options opts to rspec to support running with Guard (for failure-exit-code) #20
Conversation
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.
Thanks, @rsanheim! WDYT about support for passing options --
?
lib/turbo_tests/cli.rb
Outdated
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") do |arg| | ||
test_options << arg.strip | ||
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.
Thanks 👍 What if --
can be also used for test options similar to parallel_tests
: https://github.com/grosser/parallel_tests/blob/b85a17ebd9cf920b2052623b28f0839bc35885de/lib/parallel_tests/cli.rb#L322-L339?
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.
heya I updated the PR body w/ more context around this. tldr: I think it would be good for future PRs 😁
somesort of formatter i had went a bit crazy here
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.
some notes
else | ||
exit 1 | ||
end | ||
exit exitstatus |
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 just report the exitstatus that comes back from the Runner directly.
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.
Sounds good 👍
lib/turbo_tests/runner.rb
Outdated
if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?) | ||
SUCCESS_EXIT_CODE | ||
else | ||
wait_threads.max { |value| value.exitstatus }.value.exitstatus |
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.
Hand back the highest exit code for failures -- same as parallel-tests: https://github.com/grosser/parallel_tests/blob/01218db8d43fab939fe5b53738af1fab771373dd/lib/parallel_tests/cli.rb#L90
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.
It fails with undefined method 'exitstatus' for #<Process::Waiter:0x0000000002588318 dead> (NoMethodError)
when I test it on a big test suite.
Finished in 4 minutes 38.4 seconds (files took 26.8 seconds to load)
16001 examples, 11 failures, 1 pending, 2 errors occurred outside of examples
# ...
bundler: failed to load command: turbo_tests (/home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests)
Traceback (most recent call last):
22: from /home/serpapi/.rbenv/versions/2.7.2/bin/bundle:25:in `<main>'
21: from /home/serpapi/.rbenv/versions/2.7.2/bin/bundle:25:in `load'
20: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/exe/bundle:37:in `<top (required)>'
19: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
18: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/exe/bundle:49:in `block in <top (required)>'
17: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:25:in `start'
16: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
15: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:31:in `dispatch'
14: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
13: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
12: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
11: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:477:in `exec'
10: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:23:in `run'
9: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `kernel_load'
8: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `load'
7: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:25:in `<top (required)>'
6: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:25:in `load'
5: from /home/serpapi/Workspace/turbo_tests/bin/turbo_tests:11:in `<top (required)>'
4: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/cli.rb:101:in `run'
3: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:41:in `run'
2: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `run'
1: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `max'
/home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `block in run': undefined method `exitstatus' for #<Process::Waiter:0x0000000002588318 dead> (NoMethodError)
@@ -1,9 +1,62 @@ | |||
RSpec.describe TurboTests::CLI do | |||
subject(:output) { `bundle exec turbo_tests -f d #{fixture}`.strip } | |||
let(:bin) { Pathname(__dir__).join("../bin/turbo_tests").expand_path } |
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 isn't necessary, but nice to bypass bundler overhead if we can.
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.
Is bin
used?
Hey @ilyazub, I have this passing for |
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.
@rsanheim Cool, thanks for your work! Sorry for the late review.
For me it fails with undefined method 'exitstatus' for #<Process::Waiter:0x0000000002588318 dead> (NoMethodError)
when I test it on a big test suite. I'll try to debug it too.
else | ||
exit 1 | ||
end | ||
exit exitstatus |
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.
Sounds good 👍
@@ -1,9 +1,62 @@ | |||
RSpec.describe TurboTests::CLI do | |||
subject(:output) { `bundle exec turbo_tests -f d #{fixture}`.strip } | |||
let(:bin) { Pathname(__dir__).join("../bin/turbo_tests").expand_path } |
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.
Is bin
used?
lib/turbo_tests/runner.rb
Outdated
if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?) | ||
SUCCESS_EXIT_CODE | ||
else | ||
wait_threads.max { |value| value.exitstatus }.value.exitstatus |
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.
It fails with undefined method 'exitstatus' for #<Process::Waiter:0x0000000002588318 dead> (NoMethodError)
when I test it on a big test suite.
Finished in 4 minutes 38.4 seconds (files took 26.8 seconds to load)
16001 examples, 11 failures, 1 pending, 2 errors occurred outside of examples
# ...
bundler: failed to load command: turbo_tests (/home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests)
Traceback (most recent call last):
22: from /home/serpapi/.rbenv/versions/2.7.2/bin/bundle:25:in `<main>'
21: from /home/serpapi/.rbenv/versions/2.7.2/bin/bundle:25:in `load'
20: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/exe/bundle:37:in `<top (required)>'
19: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
18: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/exe/bundle:49:in `block in <top (required)>'
17: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:25:in `start'
16: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
15: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:31:in `dispatch'
14: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
13: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
12: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
11: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli.rb:477:in `exec'
10: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:23:in `run'
9: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `kernel_load'
8: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `load'
7: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:25:in `<top (required)>'
6: from /home/serpapi/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:25:in `load'
5: from /home/serpapi/Workspace/turbo_tests/bin/turbo_tests:11:in `<top (required)>'
4: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/cli.rb:101:in `run'
3: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:41:in `run'
2: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `run'
1: from /home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `max'
/home/serpapi/Workspace/turbo_tests/lib/turbo_tests/runner.rb:107:in `block in run': undefined method `exitstatus' for #<Process::Waiter:0x0000000002588318 dead> (NoMethodError)
Can I take over this work? |
Sure, PRs are always welcomed. 👍 |
Please do, I haven't been able to carve out time to continue it and using turbo-test via guard was always a nice to have for me. I still use turbo-test every day for full build runs and it works great for that as-is. |
Hey I'm very interested in this feature! Been using this gem on my own for a while and my team would love to use it too, but passes I haven't contributed to open source before, do you think I could help finish this PR? 😄 |
@Gloglok sure, thank you! Please also support passing test options after the end of options ( What help is needed? |
This is very out of date, and maybe has been handled upstream? In any case, closing this out. |
For #14: Allow passing custom test options via the
--test-options
flag so that turbo_tests works with Guard. I believe guard passes thru the custom exit code to parallel_tests so it can properly capture failure exit codes and keep rerunning things and not abort...and turbo tests needs the same thing to work with guard.This required tweaking how the runner reports exit statuses back to the CLI -- I wasn't super sure about that piece and how it will interact with the threads, but it is reporting the correct exit code for the limited specs I've added.
I chose not to support extra options via
--
for a few reasons:--
in the command line, and then making sure you merge in things liketags
. If I had more time I would refactor the arg parsing and test it much better in isolation (probably much like parallel-tests), and then work on getting that state to the runner in a nice, clean way.Currently all specs are passing for me locally - I thought the pending specs were failing but that was user error, I had some errant whitespace added. ✅
I also refactored the specs a bit to be easier to read with more of the state / setup close to the actual thing being tested and asserted. Hope this all makes sense to you, let me know what you think @ilyazub.