diff options
author | Matthew Draper <matthew@trebex.net> | 2019-03-01 02:14:50 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2019-03-05 01:42:44 +1030 |
commit | af986325e9da4f6c446b9adb62058e82b33cc8d4 (patch) | |
tree | 02334f6c3851b8e39f02f02b81330cb638707daf /activerecord/Rakefile | |
parent | 0c5486aa4d789bafe36b200e9c9d4507b3c20c89 (diff) | |
download | rails-af986325e9da4f6c446b9adb62058e82b33cc8d4.tar.gz rails-af986325e9da4f6c446b9adb62058e82b33cc8d4.tar.bz2 rails-af986325e9da4f6c446b9adb62058e82b33cc8d4.zip |
Copy the forking isolated test runner from railties
All the tests have a substantial chunk of identical setup effort (in
cases/helper.rb); this makes isolated tests run much faster, without any
change to the variety of how we load files.
Diffstat (limited to 'activerecord/Rakefile')
-rw-r--r-- | activerecord/Rakefile | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 90921dec8b..be2380ebdc 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -66,8 +66,28 @@ end adapter_short = adapter == "db2" ? adapter : adapter[/^[a-z0-9]+/] puts [adapter, adapter_short].inspect + dash_i = [ + "test", + "lib", + "../activesupport/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) + + # Every test file loads this first, so doing it post-fork gains + # us nothing. + require "cases/helper" + failing_files = [] + test_options = ENV["TESTOPTS"].to_s.split(/[\s]+/) + test_files = (Dir["test/cases/**/*_test.rb"].reject { |x| x.include?("/adapters/") } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).sort @@ -81,8 +101,24 @@ end test_files.each do |file| puts "--- #{file}" - success = sh(Gem.ruby, "-w", "-Itest", file) - unless success + 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.concat test_options + Rake.application = nil + + load file + } + + unless $?.success? failing_files << file puts "^^^ +++" end |