2017-08-14 17:08:09 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 17:28:46 +00:00
|
|
|
require "rake/testtask"
|
2004-11-24 01:04:44 +00:00
|
|
|
|
2016-08-06 17:38:55 +00:00
|
|
|
task default: :test
|
2013-01-01 10:03:40 +00:00
|
|
|
|
2016-01-31 18:01:03 +00:00
|
|
|
task :package
|
|
|
|
|
2013-01-01 10:03:40 +00:00
|
|
|
desc "Run all unit tests"
|
2016-08-06 17:38:55 +00:00
|
|
|
task test: "test:isolated"
|
2007-09-26 01:24:07 +00:00
|
|
|
|
2009-11-11 00:50:15 +00:00
|
|
|
namespace :test do
|
|
|
|
task :isolated do
|
2017-09-02 13:15:16 +00:00
|
|
|
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"
|
|
|
|
|
2017-09-02 13:45:43 +00:00
|
|
|
failing_files = []
|
|
|
|
|
2013-04-08 10:16:33 +00:00
|
|
|
dirs = (ENV["TEST_DIR"] || ENV["TEST_DIRS"] || "**").split(",")
|
|
|
|
test_files = dirs.map { |dir| "test/#{dir}/*_test.rb" }
|
|
|
|
Dir[*test_files].each do |file|
|
2017-09-02 13:15:16 +00:00
|
|
|
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 ¯\_(⊙︿⊙)_/¯
|
2017-09-03 16:55:26 +00:00
|
|
|
Process.waitpid fork {
|
|
|
|
ARGV.clear
|
|
|
|
Rake.application = nil
|
|
|
|
|
|
|
|
load file
|
|
|
|
}
|
2017-09-02 13:15:16 +00:00
|
|
|
|
|
|
|
unless $?.success?
|
2017-09-02 13:45:43 +00:00
|
|
|
failing_files << file
|
2017-09-02 13:15:16 +00:00
|
|
|
end
|
2010-06-24 08:56:16 +00:00
|
|
|
end
|
2017-09-02 13:45:43 +00:00
|
|
|
|
|
|
|
unless failing_files.empty?
|
|
|
|
puts
|
|
|
|
puts "Failed in:"
|
|
|
|
failing_files.each do |file|
|
|
|
|
puts " #{file}"
|
|
|
|
end
|
|
|
|
puts
|
|
|
|
|
|
|
|
raise "Failure in isolated test runner"
|
|
|
|
end
|
2009-11-11 00:50:15 +00:00
|
|
|
end
|
2006-11-02 03:34:03 +00:00
|
|
|
end
|
|
|
|
|
2016-08-06 17:28:46 +00:00
|
|
|
Rake::TestTask.new("test:regular") do |t|
|
2017-05-15 14:17:28 +00:00
|
|
|
t.libs << "test" << "#{__dir__}/../activesupport/lib"
|
2016-08-06 17:28:46 +00:00
|
|
|
t.pattern = "test/**/*_test.rb"
|
2015-08-28 02:48:46 +00:00
|
|
|
t.warning = false
|
2006-08-29 09:15:28 +00:00
|
|
|
t.verbose = true
|
2014-09-27 14:37:44 +00:00
|
|
|
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
|
2006-08-29 09:15:28 +00:00
|
|
|
end
|