mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 07:43:48 +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`
51 lines
990 B
Ruby
51 lines
990 B
Ruby
# frozen_string_literal: true
|
|
|
|
module TurboTests
|
|
class ProgressFormatter < ::TurboTests::BaseFormatter
|
|
LINE_LENGTH = 80
|
|
|
|
RSpec::Core::Formatters.register(
|
|
self,
|
|
:example_passed,
|
|
:example_pending,
|
|
:example_failed,
|
|
:start_dump,
|
|
)
|
|
|
|
def initialize(*args)
|
|
super
|
|
@examples = 0
|
|
end
|
|
|
|
def example_passed(_notification)
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap(".", :success)
|
|
wrap
|
|
end
|
|
|
|
def example_pending(_notification)
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("*", :pending)
|
|
wrap
|
|
end
|
|
|
|
def example_failed(_notification)
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("F", :failure)
|
|
wrap
|
|
end
|
|
|
|
def start_dump(_notification)
|
|
output.puts
|
|
end
|
|
|
|
private
|
|
|
|
def wrap
|
|
@examples += 1
|
|
|
|
if ENV["GITHUB_ACTIONS"] && @examples == LINE_LENGTH
|
|
output.print "\n"
|
|
@examples = 0
|
|
end
|
|
end
|
|
end
|
|
end
|