-
Notifications
You must be signed in to change notification settings - Fork 198
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
Rails 5.1.3 display regression #230
Comments
|
Same issue with 5.1.3 final released today. Both the |
there were some significant changes to Rails' minitest integration: rails/rails@0d72489 |
So heres the trouble. Minitest plugins are loaded based on being in the path of minitest/*_plugin.rb. Now that Rails uses a minitest plugin as of 5.1.3, this gem's plugin resets minitests reporters to be just its own Rails then comes along and deletes the default reporters (though they aren't there anymore, they're in delegate reporter now) and then adds its own. So now delegate reporter loops through the originals for output, and then rails reporters do their thing -- double output. I'm not sure what the best fix is in terms of fixing it from MiniTest::Reporters. |
@mttdffy could you please point the rails code which does this |
Experiencing the same thing in the final release of 5.1.3. Was able to confirm that adding this gem alone reproduces the same behavior as @bobmaerten's screenshot. I don't even need to add Commenting out |
Thanks @mttdffy for the detailed explanation. |
I might be wrong but it looks like we could just add similar line you our init to remove the reporters rails want to remove and this will fix the problem. Am I right? |
Deleting the default reporters in minitest-reporters doesn't accomplish anything. Without Rails, you end up with a DelegateReporter that does nothing because its now the only reporter, and it doesn't do anything on its own. With Rails, you end up with this:
This ends up defeating the purpose of this gem, as its no longer managing all the reporters being used. I think the biggest hurdle is the unpredictability of minitest plugin load order. It uses Gem.find_files, which doesn't seems to have a clear order to how it finds which gems are there. So theres no guarantee rails loads before or after minitest-reporters. I'm not sure there is a solution to get this to play nicely without having Rails use minitest-reporters, which isn't going to happen. In a perfect world, minitest provides a way for you to define when your plugin gets loaded, i.e. a prepend_plugin, append_plugin functionality. Then Rails would prepend to ensure its one of the first, and mini-test reporters could append, ensuring it was one of the last and could safely absorbed all the other reporters into it's DelegateReporter I guess to answer your question @os97673, it does "fix" the display issue, but DelegateReporter is now managing nothing, and the rails reporters are outside it's control and you can no longer use |
I don't understand, is there a solution for this problem? |
No, there is currently no clear way to fix it. |
Problem: An intractable conflict between the gem and the Rails 5.x test reporter: double reporting which furthermore negates the benefit of the gem's progress bar. See minitest-reporters/minitest-reporters#230. Solution: Remove gem. The gem had been added to report test results to the Rubymine IDE, which is used by at least one MO developer (@raysuelzer). But with Rails 5.0, the gem is no longer needed for that purpose. See https://www.jetbrains.com/help/ruby/minitest.html - Remove gem and all mention of it. - bundle update (also updates other gems)
here is a workaround you can add to the module Minitest
# copied from minitest
def self.init_plugins(options)
extensions.each do |name|
msg = "plugin_#{name}_init"
send msg, options if respond_to?(msg)
end
fix_reporters
end
def self.fix_reporters
dr = reporter.reporters.find { |r| r.is_a? Minitest::Reporters::DelegateReporter }
# getting rid of default reporters
drr = dr.instance_variable_get(:@reporters)
drr.delete_if { |r| r.is_a?(Minitest::SummaryReporter) || r.is_a?(Minitest::ProgressReporter) }
# getting rid of rails reporters
reporter.reporters.delete_if { |r| r.is_a?(Minitest::SuppressedSummaryReporter) || r.is_a?(::Rails::TestUnitReporter) }
end
end |
I found a cleaner workaround than the one above. AFAICT the underlying problem is Rails had this commit to make sure the Rails minitest plugin would initialize first. I think at some point that commit was lost (the file that was changed in that commit no longer exists in Rails 5.1 series, they probably missed it when cherry-picking changes around or whatever). I've raised rails/rails#30491 to track the upstream issue. You can replicate the same behaviour by adding the following to your
|
This ensures that our changes to Minitest.reporters are not trampled by other Minitest plugins, like the core Rails Minitest plugin that was introduced in Rails 5. Fixes minitest-reporters#230
This ensures that our changes to Minitest.reporters are not trampled by other Minitest plugins, like the core Rails Minitest plugin that was introduced in Rails 5. Fixes minitest-reporters#230
This ensures that our changes to Minitest.reporters are not trampled by other Minitest plugins, like the core Rails Minitest plugin that was introduced in Rails 5. Fixes minitest-reporters#230
FWIW, I started seeing this problem only after upgrading to 1.1.19 (1.1.18) was reporting fine and as expected but after updating to .19 I started seeing the duplicate reporting, reverting back to .18 resolved the issue. |
This is expected since I have reverted changes which fixed the problem in .18 because of regressions they added :( |
Is the current status that we "can't" use minitest-reporters with Rails 5.1.3+ ? |
@samcday solution works fine. |
loading local minitest-reporters does not cause problems. |
I made a PR that should fix the double reporters output rails/rails#31901 |
Nice work @Kevinrob. Thanks! |
I've just tested this in Rails 5.1.6 and it seems working just fine. No double output. |
On rails 5.1.5 bug exists. |
@likeuwill Yes. It's fixed on |
Any way to fix this in combination with Rails 5.0.7.2 (currently newest Rails 5.0)? Problem occurs with both minitest-reporters 1.1.14 as well as minitest-reporters 1.3.8. @tekniklr did you manage to fix this in Rails 5.0? |
I could fix this issue on Rails 5.0 by going back to v1.1.18. |
Hello.
Checking Rails 5.1.3.rc3 against our main application, and I find display quite broken while executing tests. I formatted output from my terminal (adding LF and removing extra spaces to fit here in the issue), it seems that default reporter still run even with Rails trick from README (Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new, ENV, Minitest.backtrace_filter`
I have no idea how things work so I only report to keep track of it.
It will eventually be resolved after Rails 5.1.3 final release, or may be it simply a minitest bug?
The text was updated successfully, but these errors were encountered: