mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't start a new process for every test file
This effectively reverts200cf32e20
, restoring a variant of5a0e0e7299
.
This commit is contained in:
parent
9ca873d222
commit
b342db680b
1 changed files with 34 additions and 10 deletions
|
@ -11,19 +11,43 @@ task test: "test:isolated"
|
|||
|
||||
namespace :test do
|
||||
task :isolated do
|
||||
dash_i = [
|
||||
"test",
|
||||
"lib",
|
||||
"../activesupport/lib",
|
||||
"../actionpack/lib",
|
||||
"../actionview/lib",
|
||||
"../activemodel/lib"
|
||||
].map { |dir| File.expand_path(dir, __dir__) }
|
||||
|
||||
dash_i.reverse_each do |x|
|
||||
$:.unshift(x) unless $:.include?(x)
|
||||
end
|
||||
$-w = true
|
||||
|
||||
require "bundler/setup" unless defined?(Bundler)
|
||||
require "active_support"
|
||||
|
||||
dirs = (ENV["TEST_DIR"] || ENV["TEST_DIRS"] || "**").split(",")
|
||||
test_files = dirs.map { |dir| "test/#{dir}/*_test.rb" }
|
||||
Dir[*test_files].each do |file|
|
||||
next true if file.include?("fixtures")
|
||||
dash_i = [
|
||||
"test",
|
||||
"lib",
|
||||
"#{__dir__}/../activesupport/lib",
|
||||
"#{__dir__}/../actionpack/lib",
|
||||
"#{__dir__}/../actionview/lib",
|
||||
"#{__dir__}/../activemodel/lib"
|
||||
]
|
||||
ruby "-w", "-I#{dash_i.join ':'}", file
|
||||
next true if file.start_with?("test/fixtures/")
|
||||
|
||||
fake_command = Shellwords.join([
|
||||
FileUtils::RUBY,
|
||||
"-w",
|
||||
*dash_i.map { |dir| "-I#{Pathname.new(dir).relative_path_from(Pathname.pwd)}" },
|
||||
file,
|
||||
])
|
||||
puts fake_command
|
||||
|
||||
# We could run these in parallel, but pretty much all of the
|
||||
# railties tests already run in parallel, so ¯\_(⊙︿⊙)_/¯
|
||||
Process.waitpid fork { ARGV.clear; load file }
|
||||
|
||||
unless $?.success?
|
||||
raise "Command failed with status (#{$?.exitstatus}): #{fake_command}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue