-
-
Notifications
You must be signed in to change notification settings - Fork 753
WIP: Removes bisect from SPEC_OPTS to prevent infinite recursion #2259
Conversation
@myronmarston any thoughts on this appreciated. Basically, I'm not sure how to test this in the test suite because of how bisect shells out (I can't set it in the SPEC_OPTS :) and I'm not sure bundling from github and experience-testing is sufficient |
@@ -291,6 +291,8 @@ def initialize_project_and_exit | |||
def bisect_and_exit(argument) | |||
RSpec::Support.require_rspec_core "bisect/coordinator" | |||
|
|||
# This might be the best spot to mutate ENV['SPEC_OPTS'] | |||
# if we do 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.
I didn't find an obvious spot in the ConfigurationOptions nor Configuration where this would go and then be available to the bisect runner, but if I check the env here at cli parsing and just pass that through the coordinator, that might be ok
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's not obvious to me what's better about this spot then the spot you already have it. Can you explain?
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.
If I'm reading code correctly, I can handle the env vars here, or multiple times in each runner.
B mobile phone
On Jun 4, 2016, at 12:47 PM, Myron Marston [email protected] wrote:
In lib/rspec/core/option_parser.rb:
@@ -291,6 +291,8 @@ def initialize_project_and_exit
def bisect_and_exit(argument)
RSpec::Support.require_rspec_core "bisect/coordinator"
# This might be the best spot to mutate ENV['SPEC_OPTS']
It's not obvious to me what's better about this spot then the spot you already have it. Can you explain?# if we do that.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
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.
Only a single Runner
instance is created for the entirety of the bisect run, so it's only going to happen once, regardless. IMO, the logic (if we take this approach) belongs better in Runner
than 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.
Surely a single instance per process...
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.
Surely a single instance per process...
A Bisect::Runner
instance is only created in the main bisect process, not in the processes created to run subsets of the suite. So yes, a single instance per main bisect process, but there's only one main bisect process for an entire --bisect
run.
It's made here in the coordinator:
runner = Runner.new(server, @original_cli_args) |
...and is then used repeatedly in the example minimizer to run specific example subsets:
results, duration = track_duration { runner.run(ids_to_run) } |
This looks like a good start. Have you tried it to confirm this actually fixes the problem? From what @JonRowe and @urbanautomaton said in #2231 it sounds like they attempted a solution like this and it didn't work even though it seems like it should. BTW, as for writing an integration test for this: we have two places for integration tests:
For this, an integration test would best belong in the latter.
What does "bundling from github" and "experience-testing" mean? |
I'm assuming that this means using RSpec as a git dependency and running yourself on the command line. BTW my pet theory for why it doesn't work, is that when Ruby spawns / forks new processes it somehow just uses the parent ENV rather than the "in ruby" environment. |
I'll investigate further in the near future. Specifically what it means to pass in an empty hash. Any thoughts on what to name this 'env spec opts without bisect' value? I think we've agreed the code for processing spec opts is in the bisect runner. I think I'll write tests that pass a non-bisect command in to confirm env behavior Eg with_env 'RSPEC_TEMP' => 'original' do Etc Thanks for your interest in this. |
I've had another quick go at this too, and now have a branch that successfully bisects with It turns out fixing the ENV is only part of the problem. The second issue is that bisection is currently invoked during options parsing, here: # lib/rspec/core/option_parser.rb
parser.on('--bisect[=verbose]', 'Repeatedly runs the suite in order to isolate the failures to the ',
' smallest reproducible case.') do |argument|
bisect_and_exit(argument)
end Because the option parser is invoked twice (once for CLI args, once for ENV args), if |
Interesting, I didn't realize the problems it was causing to perform alternate actions in the CLI parsing. The alternate action logic for I think we can refactor the options parsing so that it returns a callable for alternate actions like bisection, Thoughts? |
@urbanautomaton I suspect you're on to something. Would it make sense to open a new PR for your branch to continue discussion of that implementation? Or were you considering having @bf4 take cues from your approach? It's not clear to me if your branch is solely for illustrative purposes. https://github.com/urbanautomaton/rspec-core/blob/b7a49cab343e621bd6dccbf39e438d53fd4a43e6/lib/rspec/core/bisect/runner.rb#L92-L94 We shouldn't completely empty out |
@myronmarston said:
It does make sense to defer bisect - putting it into It looks like |
@myronmarston: I'm not sure I follow, sorry. Would the @soulcutter: I'm easy - I'm happy to open a PR for my branch if @bf4 doesn't mind.
With the approach I've taken, any args originally specified in |
While it has worked pretty OK to put the
I think the option parser would return the callable. |
|
Can use result of option parser to lookup proper action for each option. The rest is design: hash of callables? Send a method?
|
Closing in favor of #2271. |
Fixes #2231