mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 09:53:43 +08:00
b00edf3ea0
Why is this change required? By default, `RSpec` comes with a `--profile=[COUNT]` option as well but enabling that option means that the entire test suite needs to be executed. This does not work so well for `turbo_rspec` which splits our test files into various "buckets" for the tests to be executed in multiple processes. Therefore, this commit adds a similar `--profile=[COUNT]` option to `turbo_rspec` but will only profile the tests being executed. Examples: `LOAD_PLUGINS=1 bin/turbo_rspec --profile plugins/*/spec/system` or `LOAD_PLUGINS=1 bin/turbo_rspec --profile=20 plugins/*/spec/system`
24 lines
744 B
Ruby
24 lines
744 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec::Support.require_rspec_core "formatters/base_text_formatter"
|
|
RSpec::Support.require_rspec_core "formatters/console_codes"
|
|
|
|
module TurboTests
|
|
class BaseFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
|
RSpec::Core::Formatters.register(self, :dump_summary)
|
|
|
|
def dump_summary(notification, timings)
|
|
if timings.present?
|
|
output.puts "\nTop #{timings.size} Slowest examples:"
|
|
|
|
timings.each do |(full_description, source_location, duration)|
|
|
output.puts " #{full_description}"
|
|
output.puts " #{RSpec::Core::Formatters::ConsoleCodes.wrap(duration.to_s + "ms", :bold)} #{source_location}"
|
|
end
|
|
end
|
|
|
|
super(notification)
|
|
end
|
|
end
|
|
end
|