rspec / rspec-core

RSpec runner and formatters
http://rspec.info
MIT License
1.23k stars 763 forks source link

Formatters with varying color support can't control differ #2435

Open sj26 opened 7 years ago

sj26 commented 7 years ago

Howdy! πŸ‘‹ I maintain rspec_junit_formatter. It presents results in a junit xml file so that services like Jenkins can consume test results and display them richly in HTML. Currently it consumes example notifications quite nicely and can choose to use the un-colorized versions of the various strings by choosing different methods on the notification objects. πŸ‘ Unfortunately this choice doesn't extend to diffs, which are configured using the global color configuration regardless, and are already saved into the failure message by the time the formatter comes to present them. 😒

I'm not sure what the answer is here. At the moment I can probably use a clumsy regexp to grab the diff part of the message lines and clean it of ANSI codes, and will probably need to do so for current users. But perhaps there is an opportunity to parameterise the colorizer into the Differ as well through the ExceptionPresenter, or something? Perhaps they could even utilise the new extra_failure_lines somehow, if they had a way to consume a colorizer. If this sounds interesting I might try to give it a whack. πŸ˜…

sj26 commented 7 years ago

For some context, here's some output from a formatted result (which is also kinda broken for other reasons):

image

myronmarston commented 7 years ago

We're definitely open to an improvement here. Want to take a stab at it?

chrishough commented 7 years ago

Following. I am having the same problem. Were you able to fix this @sj26

sj26 commented 7 years ago

@myronmarston thanks for the blessing! I've pushed a hacky workaround into the junit formatter for now, but I'll take a stab at some diff colour options in here real soon now(tm).