提交 bbbc634e 编写于 作者: M Matthew Draper

Split railties suite in half

上级 56202d8d
......@@ -41,7 +41,8 @@ env:
global:
- "JRUBY_OPTS='--dev -J-Xmx1024M'"
matrix:
- "GEM=railties"
- "GEM=railties:1"
- "GEM=railties:2"
- "GEM=ap,ac"
- "GEM=am,amo,as,av,aj,ast"
- "GEM=as PRESERVE_TIMEZONES=1"
......
......@@ -78,10 +78,15 @@ def tasks
end
tasks
else
["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?)].compact.join(":")
["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?), subset].compact.join(":")
end
end
def subset
n = component.split(":").last
n if n =~ /\A\d+\z/
end
def key
key = [gem]
key << adapter if activerecord?
......@@ -166,7 +171,7 @@ def run_bug_report_templates
next if gem == "av:ujs" && isolated
next if gem == "guides" && isolated
next if gem =~ /:integration/ && isolated
next if gem == "railties" && isolated
next if gem =~ /railties:/ && isolated
build = Build.new(gem, isolated: isolated)
failures << build.key unless build.run!
......
......@@ -9,64 +9,81 @@ task :package
desc "Run all unit tests"
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"
failing_files = []
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.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
Rake.application = nil
load file
}
unless $?.success?
failing_files << file
end
end
run_isolated_tests = lambda do |files|
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"
unless failing_files.empty?
puts
puts "Failed in:"
failing_files.each do |file|
puts " #{file}"
end
puts
failing_files = files.reject do |file|
next true if file.start_with?("test/fixtures/")
raise "Failure in isolated test runner"
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
Rake.application = nil
load file
}
$?.success?
end
unless failing_files.empty?
puts
puts "Failed in:"
failing_files.each do |file|
puts " #{file}"
end
puts
raise "Failure in isolated test runner"
end
end
_test_files = nil
test_files = lambda do
_test_files ||= Dir[*
(ENV["TEST_DIR"] || ENV["TEST_DIRS"] || "**").
split(",").
map { |dir| "test/#{dir}/*_test.rb" }
]
end
split_filter = lambda { |file| file =~ /test\/application\// }
namespace :test do
task "1" do
run_isolated_tests.call test_files.call.select(&split_filter)
end
task "2" do
run_isolated_tests.call test_files.call.reject(&split_filter)
end
task :isolated do
run_isolated_tests.call test_files.call
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册