2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-11-01 18:57:50 -04:00
|
|
|
require "rspec/core/formatters/base_text_formatter"
|
2019-04-02 10:33:26 -04:00
|
|
|
require "parallel_tests/rspec/logger_base"
|
2013-04-25 03:17:43 -04:00
|
|
|
|
|
|
|
module Autospec
|
|
|
|
end
|
2013-11-01 18:57:50 -04:00
|
|
|
|
|
|
|
class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
2015-05-13 21:24:48 -04:00
|
|
|
RSpec::Core::Formatters.register self,
|
|
|
|
:example_passed,
|
|
|
|
:example_pending,
|
|
|
|
:example_failed,
|
|
|
|
:start_dump
|
|
|
|
|
2013-11-01 18:57:50 -04:00
|
|
|
RSPEC_RESULT = "./tmp/rspec_result"
|
|
|
|
|
|
|
|
def initialize(output)
|
2013-05-06 01:16:53 -04:00
|
|
|
super
|
2022-01-05 12:45:08 -05:00
|
|
|
FileUtils.mkdir_p("tmp") unless Dir.exist?("tmp")
|
|
|
|
File.delete(RSPEC_RESULT) if File.exist?(RSPEC_RESULT)
|
2013-11-01 18:57:50 -04:00
|
|
|
@fail_file = File.open(RSPEC_RESULT, "w")
|
2013-05-06 01:16:53 -04:00
|
|
|
end
|
|
|
|
|
2015-05-13 21:24:48 -04:00
|
|
|
def example_passed(_notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap(".", :success)
|
2013-11-01 18:57:50 -04:00
|
|
|
end
|
|
|
|
|
2015-05-13 21:24:48 -04:00
|
|
|
def example_pending(_notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("*", :pending)
|
2013-05-06 01:16:53 -04:00
|
|
|
end
|
|
|
|
|
2015-05-13 21:24:48 -04:00
|
|
|
def example_failed(notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("F", :failure)
|
2019-06-20 20:59:01 -04:00
|
|
|
@fail_file.puts(notification.example.location + " ")
|
2013-05-06 01:16:53 -04:00
|
|
|
@fail_file.flush
|
2013-04-25 03:17:43 -04:00
|
|
|
end
|
|
|
|
|
2015-05-13 21:24:48 -04:00
|
|
|
def start_dump(notification)
|
2013-11-01 18:57:50 -04:00
|
|
|
output.puts
|
|
|
|
end
|
|
|
|
|
2015-05-13 21:24:48 -04:00
|
|
|
def close(filename)
|
2013-11-01 18:57:50 -04:00
|
|
|
@fail_file.close
|
2015-05-13 21:24:48 -04:00
|
|
|
super(filename)
|
2013-11-01 18:57:50 -04:00
|
|
|
end
|
2013-04-25 03:17:43 -04:00
|
|
|
end
|