Skip to content

Commit 505a7cb

Browse files
feat: improve rspec report output
1 parent b7b9e43 commit 505a7cb

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

dump.rdb

16.7 KB
Binary file not shown.

ruby/lib/rspec/queue.rb

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,57 @@ def call(options, stdout, stderr)
291291
end
292292
end
293293

294-
# TODO: better reporting
295294
errors = supervisor.build.error_reports.sort_by(&:first).map(&:last)
296295
if errors.empty?
297296
step(green('No errors found'))
298297
0
299298
else
300299
message = errors.size == 1 ? "1 error found" : "#{errors.size} errors found"
301300
step(red(message), collapsed: false)
302-
puts errors
301+
302+
# Extract test file paths for summary
303+
test_paths = []
304+
errors.each do |error_output|
305+
# Look for the rspec rerun command (should always be present thanks to BuildStatusRecorder)
306+
# The rspec command appears on its own line, possibly after whitespace
307+
if match = error_output.match(/^\s*rspec\s+([^\s]+)(?::\d+)?/m)
308+
# Extract just the file path, removing line number if present
309+
file_path = match[1].split(':').first
310+
test_paths << file_path
311+
end
312+
end
313+
314+
# Print summary section FIRST, before any details
315+
if test_paths.any?
316+
# Count failures per file
317+
file_counts = test_paths.each_with_object(Hash.new(0)) { |path, counts| counts[path] += 1 }
318+
319+
puts "\n" + "=" * 80
320+
puts "FAILED TESTS SUMMARY:"
321+
puts "=" * 80
322+
file_counts.sort_by { |path, _| path }.each do |path, count|
323+
if count == 1
324+
puts " #{path}"
325+
else
326+
puts " #{path} (#{count} failures)"
327+
end
328+
end
329+
puts "=" * 80
330+
end
331+
332+
# Print full output of errors after the summary
333+
puts "\n" + "=" * 80
334+
puts "DETAILED ERROR INFORMATION:"
335+
puts "=" * 80
336+
337+
errors.each_with_index do |error, index|
338+
puts "\n" + "-" * 80
339+
puts "Error #{index + 1} of #{errors.size}"
340+
puts "-" * 80
341+
puts error
342+
end
343+
344+
puts "=" * 80
303345
1
304346
end
305347
end

ruby/test/integration/rspec_redis_test.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ def test_retry_report
189189
Waiting for workers to complete
190190
1 error found
191191
192+
================================================================================
193+
FAILED TESTS SUMMARY:
194+
================================================================================
195+
./spec/dummy_spec.rb
196+
================================================================================
197+
198+
================================================================================
199+
DETAILED ERROR INFORMATION:
200+
================================================================================
201+
202+
--------------------------------------------------------------------------------
203+
Error 1 of 1
204+
--------------------------------------------------------------------------------
205+
192206
Object doesn't work on first try
193207
Failure/Error: expect(1 + 1).to be == 42
194208
@@ -197,6 +211,7 @@ def test_retry_report
197211
# ./spec/dummy_spec.rb:12:in `block (2 levels) in <top (required)>'
198212
199213
rspec ./spec/dummy_spec.rb:7 # Object doesn't work on first try
214+
================================================================================
200215
EOS
201216

202217
assert_equal expected_output, normalize(out)
@@ -363,6 +378,20 @@ def test_report
363378
--- Waiting for workers to complete
364379
+++ 1 error found
365380
381+
================================================================================
382+
FAILED TESTS SUMMARY:
383+
================================================================================
384+
./spec/dummy_spec.rb
385+
================================================================================
386+
387+
================================================================================
388+
DETAILED ERROR INFORMATION:
389+
================================================================================
390+
391+
--------------------------------------------------------------------------------
392+
Error 1 of 1
393+
--------------------------------------------------------------------------------
394+
366395
Object doesn't work on first try
367396
Failure/Error: expect(1 + 1).to be == 42
368397
@@ -371,6 +400,7 @@ def test_report
371400
# ./spec/dummy_spec.rb:12:in `block (2 levels) in <top (required)>'
372401
373402
rspec ./spec/dummy_spec.rb:7 # Object doesn't work on first try
403+
================================================================================
374404
EOS
375405

376406
assert_equal expected_output, normalize(out)

0 commit comments

Comments
 (0)