Skip to content

Commit 25ad547

Browse files
feat: add brief summary of failed tests
1 parent 67f2e89 commit 25ad547

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

‎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

0 commit comments

Comments
 (0)