From 0830e43ffd4e689c80ec25d699f1af98905ab8f1 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 24 May 2019 14:01:21 +1000 Subject: [PATCH] Add FailureListFormatter that outputs failures to log/rspec-failures.log --- bin/rspec-queue | 3 ++- bin/rspec-queue-worker | 1 + lib/rspec_queue/failure_list_formatter.rb | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 lib/rspec_queue/failure_list_formatter.rb diff --git a/bin/rspec-queue b/bin/rspec-queue index 43c47ea..d487f30 100755 --- a/bin/rspec-queue +++ b/bin/rspec-queue @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'rspec_queue/server_runner' require 'rspec_queue/formatter' +require 'rspec_queue/failure_list_formatter' -ENV['SPEC_OPTS'] = "--format RSpecQueue::Formatter" unless ENV['SPEC_OPTS'] +ENV['SPEC_OPTS'] = "--format RSpecQueue::Formatter --format RSpecQueue::FailureListFormatter --out log/rspec-failures.log" unless ENV['SPEC_OPTS'] RSpecQueue::ServerRunner.invoke diff --git a/bin/rspec-queue-worker b/bin/rspec-queue-worker index 178cd29..830eb47 100755 --- a/bin/rspec-queue-worker +++ b/bin/rspec-queue-worker @@ -1,5 +1,6 @@ #!/usr/bin/env ruby require 'rspec_queue/worker_runner' require 'rspec_queue/formatter' +require 'rspec_queue/failure_list_formatter' RSpecQueue::WorkerRunner.invoke diff --git a/lib/rspec_queue/failure_list_formatter.rb b/lib/rspec_queue/failure_list_formatter.rb new file mode 100644 index 0000000..18145eb --- /dev/null +++ b/lib/rspec_queue/failure_list_formatter.rb @@ -0,0 +1,19 @@ +require 'rspec/core/formatters' + +module RSpecQueue + # Taken from rspec-core 3.9.0.pre FailureListFormatter + class FailureListFormatter < RSpec::Core::Formatters::BaseFormatter + RSpec::Core::Formatters.register self, :example_failed, :dump_profile, :message + + def example_failed(failure) + output.puts "#{failure.example.location}:#{failure.example.description}" + end + + # Discard profile and messages + # + # These outputs are not really relevant in the context of this failure + # list formatter. + def dump_profile(_profile); end + def message(_message); end + end +end