rspec / rspec-core

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

FailureListFormatter: pinpoint failure location and improve editor integration #2840

Closed paddor closed 2 years ago

paddor commented 3 years ago

Second attempt of #2839.

paddor commented 3 years ago

This second attempt tries to pinpoint the relevant source of the exception. Aggregated failures produce multiple lines in the output.

paddor commented 3 years ago

Fixed CI on Windows.

For more fine-grained matching in editors, I've included an error type (always E).

Before:

./foobar_spec.rb:12:expected false got true

After:

./foobar_spec.rb:12:E:expected false got true

Without this, it's tricky to safely distinguish these file:nr:msg lines from other lines. For example the simple errorformat='%f:%l:%m' in Vim would also recognize any line containing a timestamp as an error. Instead, errorformat='%f:%l:%t:%m' will only match lines like path:nr:type:msg.

This also allows for future extension of this formatter. For example, full backtraces could be printed as informational lines (I instead of E) if --backtrace was given.

paddor commented 3 years ago

@JonRowe @smortex

paddor commented 3 years ago

So after working with this for a day, I found myself running RSpec without -ff for a few times to see more of the backtrace. Thus, I've added support for --backtrace.

Users of this FailureListFormatter can configure their editors to either run RSpec with -ff or with -ff --backtrace to get informational (backtrace) lines along with the errors lines where the code failed. It's still the same format so capable editors can jump to the exact locations.

paddor commented 3 years ago

I've simplified it more. It always includes backtrace as informational lines. I find this the most useful output, making it very quick to follow how/where an spec failed.

Please review.

pirj commented 2 years ago

Closing as stale