aboutsummaryrefslogtreecommitdiffstats
path: root/railties/Rakefile
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-09-02 22:45:16 +0930
committerMatthew Draper <matthew@trebex.net>2017-09-03 05:15:14 +0930
commitb342db680bd18105aa903fb4da13c634fd0816f5 (patch)
tree6b867220372ce83178ec6f2e95174c2fa34f111d /railties/Rakefile
parent9ca873d222b9bf7a2d394b24df4cca66fbcc0423 (diff)
downloadrails-b342db680bd18105aa903fb4da13c634fd0816f5.tar.gz
rails-b342db680bd18105aa903fb4da13c634fd0816f5.tar.bz2
rails-b342db680bd18105aa903fb4da13c634fd0816f5.zip
Don't start a new process for every test file
This effectively reverts 200cf32e207728df287cac2ec113a7cbe277c1eb, restoring a variant of 5a0e0e72995472e315738dcea5b5a12d6e3d3489.
Diffstat (limited to 'railties/Rakefile')
-rw-r--r--railties/Rakefile44
1 files changed, 34 insertions, 10 deletions
diff --git a/railties/Rakefile b/railties/Rakefile
index d41c6e7438..500fc88fbb 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -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