@@ -66,11 +66,13 @@ namespace :test do
66
66
67
67
# Only generate the template app once.
68
68
require_relative "test/isolation/abstract_unit"
69
+ require "minitest/rails_plugin"
69
70
70
71
failing_files = [ ]
71
72
72
73
dirs = ( ENV [ "TEST_DIR" ] || ENV [ "TEST_DIRS" ] || "**" ) . split ( "," )
73
74
test_options = ENV [ "TESTOPTS" ] . to_s . split ( /[\s ]+/ )
75
+ test_options << "--profile" if ENV [ "BUILDKITE" ]
74
76
75
77
test_patterns = dirs . map { |dir | "test/#{ dir } /*_test.rb" }
76
78
test_files = Dir [ *test_patterns ] . select do |file |
@@ -94,6 +96,8 @@ namespace :test do
94
96
test_files = buckets [ n ]
95
97
end
96
98
99
+ output_file = Tempfile . new ( "railties_test_reporter" )
100
+
97
101
test_files . each do |file |
98
102
puts "--- #{ file } "
99
103
fake_command = Shellwords . join ( [
@@ -108,6 +112,7 @@ namespace :test do
108
112
# We could run these in parallel, but pretty much all of the
109
113
# railties tests already run in parallel, so ¯\_(⊙︿⊙)_/¯
110
114
Process . waitpid fork {
115
+ ENV [ "RAILTIES_OUTPUT_FILE" ] = output_file . path
111
116
ARGV . clear . concat test_options
112
117
Rake . application = nil
113
118
@@ -123,9 +128,22 @@ namespace :test do
123
128
end
124
129
end
125
130
126
- puts "--- All tests completed"
131
+ puts "+++ All tests completed"
132
+
133
+ if ENV [ "BUILDKITE" ]
134
+ TestResult = Struct . new ( :NAME , :failures , :assertions , :klass , :time , :source_location , :location )
135
+ profile = Minitest ::ProfileReporter . new ( $stdout, profile : 10 )
136
+ output_file . rewind
137
+ output_file . each_line do |result |
138
+ data = JSON . parse ( result )
139
+ profile . results << TestResult . new ( *data . values )
140
+ end
141
+
142
+ profile . summary
143
+ end
144
+
127
145
unless failing_files . empty?
128
- puts "^^^ +++"
146
+ puts "+++"
129
147
puts
130
148
puts "Failed in:"
131
149
failing_files . each do |file |
@@ -135,6 +153,9 @@ namespace :test do
135
153
136
154
exit 1
137
155
end
156
+ ensure
157
+ output_file &.close
158
+ output_file &.unlink
138
159
end
139
160
end
140
161
@@ -143,5 +164,6 @@ Rake::TestTask.new("test:regular") do |t|
143
164
t . pattern = "test/**/*_test.rb"
144
165
t . warning = true
145
166
t . verbose = true
167
+ t . options = "--profile" if ENV [ "BUILDKITE" ]
146
168
t . ruby_opts = [ "--dev" ] if defined? ( JRUBY_VERSION )
147
169
end
0 commit comments