Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Running rspec-core's specs with --order default produces an error #1073

Merged
merged 4 commits into from
Sep 14, 2013

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Sep 12, 2013

When you run:

bin/rspec --order default -b

It fails:

Failures:

  1) RSpec::Core::CommandLine configures streams before command line options
     Failure/Error: command_line.run err, out
     NoMethodError:
       private method `puts' called for nil:NilClass
     # ./lib/rspec/core/formatters/deprecation_formatter.rb:106:in `deprecation_summary'
     # ./lib/rspec/core/formatters/deprecation_formatter.rb:32:in `deprecation_summary'
     # ./lib/rspec/core/reporter.rb:127:in `block in notify'
     # ./lib/rspec/core/reporter.rb:126:in `each'
     # ./lib/rspec/core/reporter.rb:126:in `notify'
     # ./lib/rspec/core/reporter.rb:111:in `finish'
     # ./lib/rspec/core/reporter.rb:60:in `report'
     # ./lib/rspec/core/command_line.rb:25:in `run'
     # ./spec/rspec/core/command_line_spec.rb:24:in `block (2 levels) in <module:Core>'
     # ./lib/rspec/core/example.rb:114:in `instance_exec'
     # ./lib/rspec/core/example.rb:114:in `block in run'
     # ./lib/rspec/core/example.rb:181:in `call'
     # ./lib/rspec/core/example.rb:181:in `run'
     # ./spec/spec_helper.rb:114:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:68:in `instance_eval'
     # ./spec/spec_helper.rb:68:in `block in sandboxed'
     # ./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
     # ./spec/spec_helper.rb:67:in `sandboxed'
     # ./spec/spec_helper.rb:114:in `block (3 levels) in <top (required)>'
     # ./lib/rspec/core/example.rb:244:in `instance_exec'
     # ./lib/rspec/core/example.rb:244:in `instance_exec'
     # ./lib/rspec/core/hooks.rb:104:in `block (2 levels) in run'
     # ./lib/rspec/core/hooks.rb:102:in `call'
     # ./lib/rspec/core/hooks.rb:102:in `run'
     # ./lib/rspec/core/hooks.rb:446:in `run_hook'
     # ./lib/rspec/core/example_group.rb:386:in `run_around_each_hooks'
     # ./lib/rspec/core/example.rb:253:in `with_around_each_hooks'
     # ./lib/rspec/core/example.rb:111:in `run'
     # ./lib/rspec/core/example_group.rb:436:in `block in run_examples'
     # ./lib/rspec/core/example_group.rb:432:in `map'
     # ./lib/rspec/core/example_group.rb:432:in `run_examples'
     # ./lib/rspec/core/example_group.rb:417:in `run'
     # ./lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
     # ./lib/rspec/core/command_line.rb:28:in `map'
     # ./lib/rspec/core/command_line.rb:28:in `block in run'
     # ./lib/rspec/core/reporter.rb:58:in `report'
     # ./lib/rspec/core/command_line.rb:25:in `run'
     # ./lib/rspec/core/runner.rb:90:in `run'
     # ./lib/rspec/core/runner.rb:17:in `block in autorun'

Finished in 2.72 seconds
1121 examples, 1 failure, 1 pending

Failed examples:

rspec ./spec/rspec/core/command_line_spec.rb:15 # RSpec::Core::CommandLine configures streams before command line options

@JonRowe
Copy link
Member

JonRowe commented Sep 12, 2013

Looks like there's no output source loaded into the deprecation formatter?

@JonRowe
Copy link
Member

JonRowe commented Sep 12, 2013

I'm not getting this locally either on master or 2-14...

@JonRowe
Copy link
Member

JonRowe commented Sep 12, 2013

Ah, this occurs with script/test_all only, and in specific bin/rspec spec/rspec/core/formatters/html_formatter_spec.rb -b --format progress, so far only on master (not 2-14).

@JonRowe
Copy link
Member

JonRowe commented Sep 12, 2013

Ok this happens because of a new deprecation warning being triggered from stub which is changing the load order of the reporter which is causing outputstream to be nil.

@coveralls
Copy link

Coverage Status

Coverage increased (+14.39%) when pulling c93546f on fix_formatter_output_issue into 5f0e7a0 on master.

Specs that use the runner need to use the current sandbox output stream
(rather than attempting to create a new one) so that inadvertant use of
the config hasn't preloaded any formatters (e.g. deprecation warnings
will cause stuff to be initialised which would then not be captured in
our specs correctly).
@coveralls
Copy link

Coverage Status

Coverage increased (+14.38%) when pulling a22d524 on fix_formatter_output_issue into 5f0e7a0 on master.

@JonRowe
Copy link
Member

JonRowe commented Sep 14, 2013

@myronmarston had a chance to look this over?

@@ -17,7 +17,7 @@ def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
# @param [IO] out
def run(err, out)
@configuration.error_stream = err
@configuration.output_stream ||= out
@configuration.output_stream = out
Copy link
Member

Choose a reason for hiding this comment

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

Why the change? If output_stream is set to something non-nil, it seems odd (and potentially wrong) to overwrite it....

Copy link
Member Author

Choose a reason for hiding this comment

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

If you're using the runner and want to set an output stream, it seemed silly to ignore it, as if you then rely on the new output stream it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, see a6ed0c8 though. The code used to be what you changed it to, but according to that commit it changed to ||= so as to allow configured output_stream to take precedence over the default of $stdout. And that makes sense now that I think about it, too: consider that the args passed to this method originate here:

status = run(ARGV, $stderr, $stdout).to_i

CommandLine.new(options).run(err, out)

So the out arg will always be $stdout (at least from the code path as invoked by the rspec command), but the user may have configured output_stream to something else and we don't want to stomp it.

It looks like there's a missing test case for this, though; can you revert this and add one?

@myronmarston
Copy link
Member Author

Looks good in general. I do have the one question above. Otherwise, merge away.

@coveralls
Copy link

Coverage Status

Coverage increased (+14.39%) when pulling 769e6a4 on fix_formatter_output_issue into 5f0e7a0 on master.

JonRowe added a commit that referenced this pull request Sep 14, 2013
Running rspec-core's specs with `--order default` produces an error
@JonRowe JonRowe merged commit c1f3195 into master Sep 14, 2013
@JonRowe JonRowe deleted the fix_formatter_output_issue branch September 14, 2013 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants