1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/Rakefile

75 lines
1.7 KiB
Text
Raw Normal View History

# frozen_string_literal: true
require "rake/testtask"
2016-08-06 13:38:55 -04:00
task default: :test
task :package
desc "Run all unit tests"
2016-08-06 13:38:55 -04:00
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; load file }
unless $?.success?
failing_files << file
end
2010-06-24 04:56:16 -04:00
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
end
Rake::TestTask.new("test:regular") do |t|
t.libs << "test" << "#{__dir__}/../activesupport/lib"
t.pattern = "test/**/*_test.rb"
2015-08-27 22:48:46 -04:00
t.warning = false
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end