super_diff icon indicating copy to clipboard operation
super_diff copied to clipboard

super_diff removes most rspec color output when run with parallel_tests

Open fwolfst opened this issue 1 year ago • 2 comments

We use parallel_tests with rspec and rails. Once super_diff/rspec is required, most colors are stripped from the output. :(

When uncommenting Core::Formatters::ConsoleCodes (in monkey_patches.rb), the color comes back (but is gone in the colorful diff).

Seems to be in the console_code_for + wrap part, the only location I found (and I am wildly guessing here, do not understand the colorization), is in parallel_tests FailureLogger: https://github.com/search?q=repo%3Agrosser%2Fparallel_tests%20consolecodes&type=code .

fwolfst avatar Oct 26 '23 11:10 fwolfst

🤦 Seems that enabling the colors via

# rails_helper.rb
SuperDiff.configure do |config|
  config.color_enabled = true
end

solves the issue. Still strange that without parallel rspec this setting was not necessary. My problem is gone however, so can be closed if no bells ring.

fwolfst avatar Oct 26 '23 12:10 fwolfst

I suspect the following returns false as the spec suite itself does not run in a TTY session, when invoked by parallel_tests

    # lib/super_diff/configuration.rb#145
    def color_enabled_by_default?
      ENV["CI"] == "true" || $stdout.respond_to?(:tty?) && $stdout.tty?
    end

pheisiph avatar Nov 03 '23 10:11 pheisiph

Hi @fwolfst , I'm revisiting some open issues right now.

As of #261, we're mostly adopting RSpec's automatic color mode. I see that parallel_tests requests colorized output from RSpec when it itself is run in a TTY, so as of the next release, this should be fixed. Please feel free to comment on the issue again if that's not the case. You can test it out by pointing your gemspec to the main branch on this repo.

jas14 avatar Sep 22 '24 22:09 jas14