aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/Rakefile
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2019-02-13 23:58:55 +1030
committerMatthew Draper <matthew@trebex.net>2019-02-13 23:58:55 +1030
commit7724a6e98b904cb9d7ca0b135105c718e3b572d1 (patch)
treea9b72882ba7b0fdb51e8d7434d1d4fbd026f5c5f /activerecord/Rakefile
parent8d9d46fdae4502b8881eca641c51a64ee7804194 (diff)
downloadrails-7724a6e98b904cb9d7ca0b135105c718e3b572d1.tar.gz
rails-7724a6e98b904cb9d7ca0b135105c718e3b572d1.tar.bz2
rails-7724a6e98b904cb9d7ca0b135105c718e3b572d1.zip
Support running AR isolated tests in parallel
Diffstat (limited to 'activerecord/Rakefile')
-rw-r--r--activerecord/Rakefile39
1 files changed, 35 insertions, 4 deletions
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index 9824787658..90921dec8b 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -65,11 +65,42 @@ end
task adapter => "#{adapter}:env" do
adapter_short = adapter == "db2" ? adapter : adapter[/^[a-z0-9]+/]
puts [adapter, adapter_short].inspect
- (Dir["test/cases/**/*_test.rb"].reject {
+
+ failing_files = []
+
+ test_files = (Dir["test/cases/**/*_test.rb"].reject {
|x| x.include?("/adapters/")
- } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
- sh(Gem.ruby, "-w", "-Itest", file)
- end || raise("Failures")
+ } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).sort
+
+ if ENV["BUILDKITE_PARALLEL_JOB_COUNT"]
+ n = ENV["BUILDKITE_PARALLEL_JOB"].to_i
+ m = ENV["BUILDKITE_PARALLEL_JOB_COUNT"].to_i
+
+ test_files = test_files.each_slice(m).map { |slice| slice[n] }.compact
+ end
+
+ test_files.each do |file|
+ puts "--- #{file}"
+ success = sh(Gem.ruby, "-w", "-Itest", file)
+ unless success
+ failing_files << file
+ puts "^^^ +++"
+ end
+ puts
+ end
+
+ puts "--- All tests completed"
+ unless failing_files.empty?
+ puts "^^^ +++"
+ puts
+ puts "Failed in:"
+ failing_files.each do |file|
+ puts " #{file}"
+ end
+ puts
+
+ exit 1
+ end
end
end
end