Skip to content
This repository

Deprecation warnings and other "puts" cause formatting issues #7

Closed
kvirani opened this Issue November 19, 2010 · 16 comments

4 participants

Khurram Virani Jeff Felchner Jeff Kreeftmeijer Gonzalo Rodríguez-Baltanás Díaz
Khurram Virani

Any output from the app during testing should perhaps be displayed somewhere else instead of at the current cursor - if that is possible.

This will avoid any mis-formatting which I think makes this format at times harder to read than the rspec default.

Is there a known workaround for this by using some kind of STDOUT redirect?

Jeff Felchner
Owner

I think your best bet here is to use a logger instead of STDOUT. tail -f followed by the log file name should get you the results you're looking for.

Anyone have any other thoughts?

Khurram Virani

How does that alleviate the Rails Deprecation Warnings ?

Khurram Virani

Actually Dep Warnings currently go to the logger according to my development.rb but they still end up appearing in the console amongst the fuubar output ...

Jeff Felchner
Owner

Sorry Khurram, I didn't see the "Deprecation Warnings" part of your title. Just from what I know I think this would have to be done on a per-gem basis.

In their gem they could do something like STDOUT.tty? and the like but I believe the valid argument would be that deprecation warnings should be an eyesore and a nag because something needs to be done about them.

Jeff Kreeftmeijer
Collaborator

Fuubar should leave the terminal output alone as much as possible. Like Jeff said, warnings are supposed to be an eyesore.

What we could do is directly print the progress bar again after outputting other things. That would give you multiple bars on your screen, but at least the output/warnings won't mess up the last progress bar.

Thoughts? :)

Gonzalo Rodríguez-Baltanás Díaz

Hi,

I too miss the ability to see the output of puts statements, since they are really useful for debugging.

What I would like to see when using Fuubar and a put statement is something along these lines:

All examples were filtered out; ignoring {:focus=>true}
 48/48 |===================================================================================== 100 ======================================================================================>| Time: 00:00:02 

Finished in 2.34 seconds
48 examples, 0 failures

Logged output:

GET /api/v1/badges/:id
   behaves like a getable resource
     return resource

My outputed message here     
       with :name

So basically you will see the Fuubar style as it is right now, but for samples where STDOUT is used it will also print them is documentation style at the end of the test suite execution.

Jeff Felchner
Owner

Unfortunately there's nothing that can be done here. The formatter works like a typewriter. You can type on the current line and you can go to the next line, but you can't go back up.

When you puts inside of a program, it is putsing to STDOUT and it knows NOTHING of what Fuubar is doing (or anything else happening in the terminal).

The only thing which could be done here is if we made a Fuubar.puts method which could clear the bar, puts some output and then redraw the bar.

I am actually going to be implementing something like this in jfelchner/ruby-progressbar so it would be a trivial delegation. It feels kind of icky and I think this may be outside the scope of what Fuubar should be responsible for.

I'll reply back here when I'm done with the progress bar implementation.

Jeff Felchner
Owner

@Nerian there is currently no way that I know of to do what you're saying with RSpec formatters.

Jeff Felchner
Owner

To keep track of the progress of progressbar.puts see the issue here: jfelchner/ruby-progressbar#32

Jeff Felchner
Owner

I've implemented this in ruby-progressbar here: 87b1613

It will be going out in v1.2 and I will add something to accommodate this in Fuubar as well.

Jeff Felchner jfelchner closed this August 15, 2013
Jeff Felchner
Owner

Just pushed v1.2 of fuubar which adds a message method. In order to get access to this, you will need to retrieve the instance of fuubar from RSpec. For example:

fuubar = RSpec.configuration.formatters.first
fuubar.message "My log message"
Gonzalo Rodríguez-Baltanás Díaz

I have this error since I updated to v1.2. I am using rspec (2.14.1)

Exception encountered: #<NoMethodError: undefined method `log' for nil:NilClass>
backtrace:
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/fuubar-1.2.0/lib/fuubar.rb:45:in `message'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/reporter.rb:127:in `block in notify'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/reporter.rb:126:in `each'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/reporter.rb:126:in `notify'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/reporter.rb:70:in `message'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/world.rb:73:in `announce_filters'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:23:in `run'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in `run_tests'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/Nerian/.rvm/gems/ruby-2.0.0-p247@eucalipto/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/Nerian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/drb/drb.rb:1588:in `perform_without_block'
/Users/Nerian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/drb/drb.rb:1548:in `perform'
/Users/Nerian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/drb/drb.rb:1626:in `block (2 levels) in main_loop'
/Users/Nerian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/drb/drb.rb:1622:in `loop'
/Users/Nerian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/drb/drb.rb:1622:in `block in main_loop'
Jeff Felchner
Owner

@Nerian it may be spork that's causing wonkiness, but you can only use #message once the reporter has started. Before that point, there is no progressbar to send messages to.

Jeff Felchner
Owner

Oh nope, I see what the problem is.

I'll get a fix out right now.

Jeff Felchner jfelchner reopened this August 16, 2013
Jeff Felchner
Owner

Ok @Nerian, I yanked version 1.2.0 and pushed version 1.2.1. That should take care of it. Thanks for reporting the issue.

Jeff Felchner jfelchner closed this August 16, 2013
Gonzalo Rodríguez-Baltanás Díaz

All good now, thanks :thumbsup:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.