Skip to content

Commit bbbc634

Browse files
committed
Split railties suite in half
1 parent 56202d8 commit bbbc634

File tree

3 files changed

+81
-58
lines changed

3 files changed

+81
-58
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ env:
4141
global:
4242
- "JRUBY_OPTS='--dev -J-Xmx1024M'"
4343
matrix:
44-
- "GEM=railties"
44+
- "GEM=railties:1"
45+
- "GEM=railties:2"
4546
- "GEM=ap,ac"
4647
- "GEM=am,amo,as,av,aj,ast"
4748
- "GEM=as PRESERVE_TIMEZONES=1"

ci/travis.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ def tasks
7878
end
7979
tasks
8080
else
81-
["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?)].compact.join(":")
81+
["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?), subset].compact.join(":")
8282
end
8383
end
8484

85+
def subset
86+
n = component.split(":").last
87+
n if n =~ /\A\d+\z/
88+
end
89+
8590
def key
8691
key = [gem]
8792
key << adapter if activerecord?
@@ -166,7 +171,7 @@ def run_bug_report_templates
166171
next if gem == "av:ujs" && isolated
167172
next if gem == "guides" && isolated
168173
next if gem =~ /:integration/ && isolated
169-
next if gem == "railties" && isolated
174+
next if gem =~ /railties:/ && isolated
170175

171176
build = Build.new(gem, isolated: isolated)
172177
failures << build.key unless build.run!

railties/Rakefile

Lines changed: 72 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,81 @@ task :package
99
desc "Run all unit tests"
1010
task test: "test:isolated"
1111

12-
namespace :test do
13-
task :isolated do
14-
dash_i = [
15-
"test",
16-
"lib",
17-
"../activesupport/lib",
18-
"../actionpack/lib",
19-
"../actionview/lib",
20-
"../activemodel/lib"
21-
].map { |dir| File.expand_path(dir, __dir__) }
22-
23-
dash_i.reverse_each do |x|
24-
$:.unshift(x) unless $:.include?(x)
25-
end
26-
$-w = true
27-
28-
require "bundler/setup" unless defined?(Bundler)
29-
require "active_support"
30-
31-
failing_files = []
32-
33-
dirs = (ENV["TEST_DIR"] || ENV["TEST_DIRS"] || "**").split(",")
34-
test_files = dirs.map { |dir| "test/#{dir}/*_test.rb" }
35-
Dir[*test_files].each do |file|
36-
next true if file.start_with?("test/fixtures/")
37-
38-
fake_command = Shellwords.join([
39-
FileUtils::RUBY,
40-
"-w",
41-
*dash_i.map { |dir| "-I#{Pathname.new(dir).relative_path_from(Pathname.pwd)}" },
42-
file,
43-
])
44-
puts fake_command
45-
46-
# We could run these in parallel, but pretty much all of the
47-
# railties tests already run in parallel, so ¯\_(⊙︿⊙)_/¯
48-
Process.waitpid fork {
49-
ARGV.clear
50-
Rake.application = nil
51-
52-
load file
53-
}
54-
55-
unless $?.success?
56-
failing_files << file
57-
end
58-
end
12+
run_isolated_tests = lambda do |files|
13+
dash_i = [
14+
"test",
15+
"lib",
16+
"../activesupport/lib",
17+
"../actionpack/lib",
18+
"../actionview/lib",
19+
"../activemodel/lib"
20+
].map { |dir| File.expand_path(dir, __dir__) }
21+
22+
dash_i.reverse_each do |x|
23+
$:.unshift(x) unless $:.include?(x)
24+
end
25+
$-w = true
26+
27+
require "bundler/setup" unless defined?(Bundler)
28+
require "active_support"
5929

60-
unless failing_files.empty?
61-
puts
62-
puts "Failed in:"
63-
failing_files.each do |file|
64-
puts " #{file}"
65-
end
66-
puts
30+
failing_files = files.reject do |file|
31+
next true if file.start_with?("test/fixtures/")
6732

68-
raise "Failure in isolated test runner"
33+
fake_command = Shellwords.join([
34+
FileUtils::RUBY,
35+
"-w",
36+
*dash_i.map { |dir| "-I#{Pathname.new(dir).relative_path_from(Pathname.pwd)}" },
37+
file,
38+
])
39+
puts fake_command
40+
41+
# We could run these in parallel, but pretty much all of the
42+
# railties tests already run in parallel, so ¯\_(⊙︿⊙)_/¯
43+
Process.waitpid fork {
44+
ARGV.clear
45+
Rake.application = nil
46+
47+
load file
48+
}
49+
50+
$?.success?
51+
end
52+
53+
unless failing_files.empty?
54+
puts
55+
puts "Failed in:"
56+
failing_files.each do |file|
57+
puts " #{file}"
6958
end
59+
puts
60+
61+
raise "Failure in isolated test runner"
62+
end
63+
end
64+
65+
_test_files = nil
66+
test_files = lambda do
67+
_test_files ||= Dir[*
68+
(ENV["TEST_DIR"] || ENV["TEST_DIRS"] || "**").
69+
split(",").
70+
map { |dir| "test/#{dir}/*_test.rb" }
71+
]
72+
end
73+
74+
split_filter = lambda { |file| file =~ /test\/application\// }
75+
76+
namespace :test do
77+
task "1" do
78+
run_isolated_tests.call test_files.call.select(&split_filter)
79+
end
80+
81+
task "2" do
82+
run_isolated_tests.call test_files.call.reject(&split_filter)
83+
end
84+
85+
task :isolated do
86+
run_isolated_tests.call test_files.call
7087
end
7188
end
7289

0 commit comments

Comments
 (0)