Skip to content
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

Progress bar defaults to 80 character length when ran through Spring on Rails #69

Closed
brandonweiss opened this issue Apr 22, 2014 · 13 comments
Labels
outdated Inactive - Outdated

Comments

@brandonweiss
Copy link

I've been working on improving the ProgressReporter on minitest-reporters, and I recently switched it from using PowerBar to ruby-progressbar. This fixed a performance issue and enabled a few other improvements, but I noticed an issue minitest-reporters/minitest-reporters#106.

As I mentioned in the issue I read through LengthCalculator but my knowledge of how terminals work isn't deep enough to understand why this is happening or if there's a fix, and if that fix should be on ruby-progressbar or not. Thoughts?

@jfelchner
Copy link
Owner

@brandonweiss there are multiple places where it gives up and defaults to 80 characters. If you could add some puts statements locally to figure out which one is actually being fired, that would help a lot in tracking down exactly what's going on.

@brandonweiss
Copy link
Author

Ah, OK, what seems to be happening is IO.console is nil, so when winsize is called on it an exception is raised, which is rescued and returns 80 in terminal_width.

@jfelchner
Copy link
Owner

@brandonweiss my guess (and I don't know this for a fact) is that spring is buffering the output through its own IO object first, then it's outputting it to the screen.

Because of this, the bar has no console with which to check it's width.

Your only option for a full width bar at that point would be to manually set the ENV variable that progressbar checks before it does it's calculation.

@jfelchner
Copy link
Owner

@brandonweiss I'm going to leave this issue open as long as it's still being researched. I want to make sure it's not a problem with ruby-progressbar. Let me know what you find.

@brandonweiss
Copy link
Author

Yeah I'm researching it now. Will do!

@jfelchner
Copy link
Owner

Also, off the subject, but just wait till you see what I have in store for the next version of the gem. 😄 It'll be especially applicable to a test reporter.

I'm going to add "buckets" to the bar. So that you'll essentially be able to do something like this:

|++++++=======--------->                           |

Where the '+' might be a red =, the "=" might be a yellow = and the "-" might be a green =. Allowing you to visually see a rough percentage of failed/pending/successful tests.

@brandonweiss
Copy link
Author

Yes! I was initially trying to do that, until I realized that it's not possible in the way a normal reporter with dots can do it, because the bar is redrawn every time. So I settled for the whole bar changing color. But it would certainly be awesome to be able to colorize part of it.

@jfelchner
Copy link
Owner

Hey @brandonweiss any progress on this?

@brandonweiss
Copy link
Author

Sorry, I've got an issue open (rails/spring#296) on spring, I just haven't heard back yet.

@jfelchner
Copy link
Owner

@brandonweiss awesome. No problem. Tell ya what, I'm going to close this issue for now since it's not really an issue with the progressbar. If/when they get back to you, just ping me back on this issue and I'll reopen in.

@brandonweiss
Copy link
Author

👍

@jfelchner jfelchner mentioned this issue May 8, 2014
@qd3v
Copy link

qd3v commented Aug 26, 2014

Just if someone needs a temporary solution (this is guard+rspec+spring+fuubar on OS X example):

guard :rspec, cmd: 'RUBY_PROGRESS_BAR_LENGTH=`tput cols` bin/rspec' do
end

or add this line in bin/rspec

#!/usr/bin/env ruby
begin
  ENV['RUBY_PROGRESS_BAR_LENGTH'] ||= `tput cols`.chomp # <---
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the outdated Inactive - Outdated label Dec 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated Inactive - Outdated
Projects
None yet
Development

No branches or pull requests

3 participants