mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
DEV: Add parallel spec support to autospec
Set PARALLEL_SPEC=1 to use this functionality
This commit is contained in:
@ -15,7 +15,17 @@ module Autospec
|
|||||||
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", specs.split].flatten.join(" ")
|
"-f", "Autospec::Formatter"]
|
||||||
|
|
||||||
|
command = begin
|
||||||
|
if ENV["PARALLEL_SPEC"] &&
|
||||||
|
!specs.split.any? { |s| puts s; s =~ /\:/ } # Parallel spec can't run specific groups
|
||||||
|
"parallel_rspec -- #{args.join(" ")} -- #{specs.split.join(" ")}"
|
||||||
|
else
|
||||||
|
"bin/rspec #{args.join(" ")} #{specs.split.join(" ")}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# launch rspec
|
# launch rspec
|
||||||
Dir.chdir(Rails.root) do
|
Dir.chdir(Rails.root) do
|
||||||
env = { "RAILS_ENV" => "test" }
|
env = { "RAILS_ENV" => "test" }
|
||||||
@ -25,7 +35,7 @@ module Autospec
|
|||||||
end
|
end
|
||||||
pid =
|
pid =
|
||||||
@mutex.synchronize do
|
@mutex.synchronize do
|
||||||
@pid = Process.spawn(env, "bin/rspec #{args}")
|
@pid = Process.spawn(env, command)
|
||||||
end
|
end
|
||||||
|
|
||||||
_, status = Process.wait2(pid)
|
_, status = Process.wait2(pid)
|
||||||
|
Reference in New Issue
Block a user