DEV: Print proper summary when errors have been reporter in turbo_rspec

This commit is contained in:
Guo Xiang Tan 2020-06-23 13:34:58 +08:00
parent add2a9411e
commit 1157d2a0ff
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
3 changed files with 26 additions and 12 deletions

View File

@ -9,6 +9,7 @@ module TurboTests
:example_failed, :example_failed,
:example_passed, :example_passed,
:example_pending, :example_pending,
:message,
:seed :seed
) )
@ -95,6 +96,13 @@ module TurboTests
) )
end end
def message(notification)
output_row(
type: :message,
message: notification.message
)
end
private private
def output_row(obj) def output_row(obj)

View File

@ -27,6 +27,8 @@ module TurboTests
@failed_examples = [] @failed_examples = []
@all_examples = [] @all_examples = []
@start_time = start_time @start_time = start_time
@messages = []
@errors_outside_of_examples_count = 0
end end
def add(name, outputs) def add(name, outputs)
@ -63,6 +65,15 @@ module TurboTests
@failed_examples << example @failed_examples << example
end end
def message(message)
delegate_to_formatters(:message, RSpec::Core::Notifications::MessageNotification.new(message))
@messages << message
end
def error_outside_of_examples
@errors_outside_of_examples_count += 1
end
def finish def finish
end_time = Time.now end_time = Time.now
@ -86,7 +97,7 @@ module TurboTests
@failed_examples, @failed_examples,
@pending_examples, @pending_examples,
0, 0,
0 @errors_outside_of_examples_count
) )
) )
delegate_to_formatters(:close, delegate_to_formatters(:close,

View File

@ -44,7 +44,6 @@ module TurboTests
group_opts = {} group_opts = {}
if use_runtime_info if use_runtime_info
FileUtils.rm("tmp/turbo_rspec_runtime.log", force: true)
group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log" group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log"
else else
group_opts[:group_by] = :filesize group_opts[:group_by] = :filesize
@ -189,14 +188,12 @@ module TurboTests
@messages << { type: 'exit', process_id: process_id } @messages << { type: 'exit', process_id: process_id }
end end
stdout_thread = start_copy_thread(stdout, STDOUT) @threads << start_copy_thread(stdout, STDOUT)
stderr_thread = start_copy_thread(stderr, STDERR) @threads << start_copy_thread(stderr, STDERR)
@threads << stdout_thread
@threads << stderr_thread
@threads << Thread.new do @threads << Thread.new do
if wait_thr.value.exitstatus != 0 if wait_thr.value.exitstatus != 0
@messages << { type: 'error', record_runtime: record_runtime } @messages << { type: 'error' }
end end
end end
end end
@ -238,15 +235,13 @@ module TurboTests
@threads.each(&:kill) @threads.each(&:kill)
break break
end end
when 'message'
@reporter.message(message[:message])
when 'seed' when 'seed'
when 'close' when 'close'
when 'error' when 'error'
if message[:record_runtime] @reporter.error_outside_of_examples
STDERR.puts File.read("tmp/turbo_rspec_runtime.log")
end
@threads.each(&:kill)
@error = true @error = true
break
when 'exit' when 'exit'
exited += 1 exited += 1
if exited == @num_processes + 1 if exited == @num_processes + 1