mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 10:45:17 +08:00
DEV: Use parallel-compatible formatter for logging autospec failures
The old method would cause the parallel processes to overwrite each other. The parallel formatter allows multiple processes to write to the same file.
This commit is contained in:
parent
a2c6683e3b
commit
02ed5e78e1
|
@ -1,4 +1,5 @@
|
||||||
require "rspec/core/formatters/base_text_formatter"
|
require "rspec/core/formatters/base_text_formatter"
|
||||||
|
require "parallel_tests/rspec/logger_base"
|
||||||
|
|
||||||
module Autospec; end
|
module Autospec; end
|
||||||
|
|
||||||
|
@ -43,3 +44,18 @@ class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Autospec::ParallelFormatter < ParallelTests::RSpec::LoggerBase
|
||||||
|
RSpec::Core::Formatters.register self, :example_failed
|
||||||
|
|
||||||
|
def message(*args);end
|
||||||
|
def dump_failures(*args);end
|
||||||
|
def dump_summary(*args);end
|
||||||
|
def dump_pending(*args);end
|
||||||
|
def seed(*args);end
|
||||||
|
|
||||||
|
def example_failed(notification)
|
||||||
|
output.puts notification.example.metadata[:location] + " "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,18 @@ module Autospec
|
||||||
self.abort
|
self.abort
|
||||||
end
|
end
|
||||||
# we use our custom rspec formatter
|
# we use our custom rspec formatter
|
||||||
args = ["-r", "#{File.dirname(__FILE__)}/formatter.rb",
|
args = ["-r", "#{File.dirname(__FILE__)}/formatter.rb"]
|
||||||
"-f", "Autospec::Formatter"]
|
|
||||||
|
|
||||||
command = begin
|
command = begin
|
||||||
if ENV["PARALLEL_SPEC"] &&
|
if ENV["PARALLEL_SPEC"] &&
|
||||||
!specs.split.any? { |s| puts s; s =~ /\:/ } # Parallel spec can't run specific groups
|
!specs.split.any? { |s| puts s; s =~ /\:/ } # Parallel spec can't run specific groups
|
||||||
|
|
||||||
|
args += ["-f", "progress", "-f", "Autospec::ParallelFormatter", "-o", "./tmp/rspec_result"]
|
||||||
|
args += ["-f", "ParallelTests::RSpec::RuntimeLogger", "-o", "./tmp/parallel_runtime_rspec.log"] if specs == "spec"
|
||||||
|
|
||||||
"parallel_rspec -- #{args.join(" ")} -- #{specs.split.join(" ")}"
|
"parallel_rspec -- #{args.join(" ")} -- #{specs.split.join(" ")}"
|
||||||
else
|
else
|
||||||
|
args += ["-f", "Autospec::Formatter"]
|
||||||
"bin/rspec #{args.join(" ")} #{specs.split.join(" ")}"
|
"bin/rspec #{args.join(" ")} #{specs.split.join(" ")}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user