-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Outputting seed before loading files creates reporter too early #695
Comments
@grk I think it should be part of the "run options" output, but that requires some refactoring. I actually started to do this but haven't gotten very far so you're welcome to give it a shot. Just comment here that you're working on it so we don't duplicate the effort. |
@dchelimsky that looks like a bit too much for me atm. I'll just keep an eye on this issue and monkeypatch what I need from head to a stable release :) |
Perhaps a quick workaround would be to just puts the seed instead of using the reporter? |
That's not a legit option because output can go to a file. |
Three other possible solutions that come to mind:
Of these options, I think I like #2 the best. Thoughts from others? @mscottford, it'd be good to have you weigh in as well since you came up with the original change. Which of the above would meet your needs? |
I think this belongs in the run options, e.g. Run options:
order: random (seed 1234)
include {:focus=>true}
exclude {:ruby=>#<Proc:./spec/spec_helper.rb:109>} |
Is there an option 4 that conditionally (controlled by a command line parameter) outputs the seed to STDERR before the run? |
@dchelimsky Sorry, I'm not familiar enough with the run options to see how that solves the problem. Do you mind being a little more pedantic? |
@mscottford it's actually orthogonal to the problem (may or may not fix it automatically), but however the issue is solved, there is a place to display run options and that should include order as well as filters. Does that make sense? |
@dchelimsky Got it. As long as the run options are displayed before files are loaded, then that's probably a better approach than what I originally did... I'll go take a peek. [imagine that time has passed...] I don't think that'll fix it all by itself. See: https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/command_line.rb#L27 To solve the issue that I ran into, we would need to call Thoughts? |
@dchelimsky -- putting it in the run options output makes sense, but that's not going to address @mscottford's need. The run options are printed after all spec files have been loaded, so if an error occurs while loading the files, it will exit before printing the run options. The run options (as currently exists) can't be printed before loading the spec files because the output depends on what has been loaded; for example, it can print things like "All examples were filtered out". @mscottford -- we talked a bit about this in your original PR, but I want to revisit it:
In the current gem release of rspec, the order files get loaded is essentially unspecified (it delegates to the operating system's order). With the change in #660, the load order in the next minor release will be fixed at alphabetical order -- so if an error occurs while loading the files, it'll be consistently reproducible without knowing the random seed, in fact, the random seed won't have done anything yet at that point. Printing the random seed off at the start isn't going to help you troubleshoot. Maybe I'm missing something, but I don't see how printing the random seed at the start will actually help you troubleshoot the sorts of load-time issues you mentioned when you opened the PR. In fact, printing the random seed at the start may actually be unhelpful because it suggests the randomization has done something at that point, and it hasn't. So...I'm considering reverting the change from #660, but I want to make sure I'm not misunderstanding your problem first. Regardless, I think printing the random seed in the run options (as @dchelimsky suggests) at the start of the spec run makes sense, but that can be a separate improvement entirely. |
I was perhaps making an incorrect assumption. I thought the order the files were loaded was also randomized by that seed. I thought I had seen code to that affect, but I can't find it now... |
The random seed is used for two things:
The order the spec files are loaded is a separate thing. |
Okay. Then it looks like I solved a problem that did not exist. My apologies. In that case, please keep #660 around, or provide another way to control the file ordering. |
It looks like fb0f06e (merging #676) created a regression: by calling
@configuration.reporter.notify
before@configuration.load_spec_files
(and thus memoizing the reporter too early), it breaks adding formatters in configuration block in spec_helper.rb.A simple fix would be to add another reporter for this message, or revert this merge until a better solution is found.
I'd like to fix it, but maybe someone has a proper solution?
The text was updated successfully, but these errors were encountered: