55require 'ci/queue'
66require 'rspec/queue/build_status_recorder'
77require 'rspec/queue/order_recorder'
8+ require 'rspec/queue/error_report'
89
910module RSpec
1011 module Queue
@@ -291,16 +292,56 @@ def call(options, stdout, stderr)
291292 end
292293 end
293294
294- # TODO: better reporting
295- errors = supervisor . build . error_reports . sort_by ( &:first ) . map ( &:last )
295+ errors = supervisor . build . error_reports . sort_by ( &:first ) . map do |_ , error_data |
296+ RSpec ::Queue ::ErrorReport . load ( error_data )
297+ end
296298 if errors . empty?
297299 step ( green ( 'No errors found' ) )
298300 0
299301 else
300302 message = errors . size == 1 ? "1 error found" : "#{ errors . size } errors found"
301303 step ( red ( message ) , collapsed : false )
302- puts errors
304+
305+ pretty_print_summary ( errors )
306+ pretty_print_failures ( errors )
303307 1
308+ # Example output
309+ #
310+ # FAILED TESTS SUMMARY:
311+ # =================================================================================
312+ # ./spec/dummy_spec.rb
313+ # ./spec/dummy_spec_2.rb (2 failures)
314+ # ./spec/dummy_spec_3.rb (3 failures)
315+ # =================================================================================
316+ #
317+ # --------------------------------------------------------------------------------
318+ # Error 1 of 3
319+ # --------------------------------------------------------------------------------
320+ #
321+ # Object doesn't work on first try
322+ # Failure/Error: expect(1 + 1).to be == 42
323+ #
324+ # expected: == 42
325+ # got: 2
326+ #
327+ # --- stacktrace will be here ---
328+ # --- rerun command will be here ---
329+ #
330+ # --------------------------------------------------------------------------------
331+ # Error 2 of 3
332+ # --------------------------------------------------------------------------------
333+ #
334+ # Object doesn't work on first try
335+ # Failure/Error: expect(1 + 1).to be == 42
336+ #
337+ # expected: == 42
338+ # got: 2
339+ #
340+ # --- stacktrace will be here ---
341+ # --- rerun command will be here ---
342+ #
343+ # ... etc
344+ # =================================================================================
304345 end
305346 end
306347
@@ -320,6 +361,38 @@ def setup(options, out, err)
320361 invalid_usage! ( 'Missing --queue parameter' ) unless queue_url
321362 invalid_usage! ( 'Missing --build parameter' ) unless RSpec ::Queue . config . build_id
322363 end
364+
365+ private
366+
367+ def pretty_print_summary ( errors )
368+ test_paths = errors . map ( &:test_file ) . compact
369+ return unless test_paths . any?
370+
371+ file_counts = test_paths . each_with_object ( Hash . new ( 0 ) ) { |path , counts | counts [ path ] += 1 }
372+
373+ puts "\n " + "=" * 80
374+ puts "FAILED TESTS SUMMARY:"
375+ puts "=" * 80
376+ file_counts . sort_by { |path , _ | path } . each do |path , count |
377+ if count == 1
378+ puts " #{ path } "
379+ else
380+ puts " #{ path } (#{ count } failures)"
381+ end
382+ end
383+ puts "=" * 80
384+ end
385+
386+ def pretty_print_failures ( errors )
387+ errors . each_with_index do |error , index |
388+ puts "\n " + "-" * 80
389+ puts "Error #{ index + 1 } of #{ errors . size } "
390+ puts "-" * 80
391+ puts error . to_s
392+ end
393+
394+ puts "=" * 80
395+ end
323396 end
324397
325398 class QueueReporter < SimpleDelegator
@@ -362,7 +435,18 @@ def setup(err, out)
362435 invalid_usage! ( 'Missing --queue parameter' ) unless queue_url
363436 invalid_usage! ( 'Missing --build parameter' ) unless RSpec ::Queue . config . build_id
364437 invalid_usage! ( 'Missing --worker parameter' ) unless RSpec ::Queue . config . worker_id
365- RSpec . configuration . backtrace_formatter . filter_gem ( 'ci-queue' )
438+ RSpec . configure do |config |
439+ config . backtrace_exclusion_patterns = [
440+ # Filter bundler paths
441+ %r{/tmp/bundle/} ,
442+ # RSpec internals
443+ %r{/gems/rspec-} ,
444+ # ci-queue and rspec-queue internals
445+ %r{exe/rspec-queue} ,
446+ %r{lib/ci/queue/} ,
447+ %r{rspec/queue}
448+ ]
449+ end
366450 end
367451
368452 def run_specs ( example_groups )
0 commit comments