@@ -66,12 +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 ]+/ )
74
- test_options << "--profile" if ENV [ "CI " ]
75
+ test_options << "--profile" if ENV [ "BUILDKITE " ]
75
76
76
77
test_patterns = dirs . map { |dir | "test/#{ dir } /*_test.rb" }
77
78
test_files = Dir [ *test_patterns ] . select do |file |
@@ -95,6 +96,8 @@ namespace :test do
95
96
test_files = buckets [ n ]
96
97
end
97
98
99
+ output_file = Tempfile . new ( "railties_test_reporter" )
100
+
98
101
test_files . each do |file |
99
102
puts "--- #{ file } "
100
103
fake_command = Shellwords . join ( [
@@ -109,6 +112,7 @@ namespace :test do
109
112
# We could run these in parallel, but pretty much all of the
110
113
# railties tests already run in parallel, so ¯\_(⊙︿⊙)_/¯
111
114
Process . waitpid fork {
115
+ ENV [ "RAILTIES_OUTPUT_FILE" ] = output_file . path
112
116
ARGV . clear . concat test_options
113
117
Rake . application = nil
114
118
@@ -124,9 +128,22 @@ namespace :test do
124
128
end
125
129
end
126
130
127
- 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
+
128
145
unless failing_files . empty?
129
- puts "^^^ +++"
146
+ puts "+++"
130
147
puts
131
148
puts "Failed in:"
132
149
failing_files . each do |file |
@@ -136,6 +153,9 @@ namespace :test do
136
153
137
154
exit 1
138
155
end
156
+ ensure
157
+ output_file &.close
158
+ output_file &.unlink
139
159
end
140
160
end
141
161
@@ -144,6 +164,6 @@ Rake::TestTask.new("test:regular") do |t|
144
164
t . pattern = "test/**/*_test.rb"
145
165
t . warning = true
146
166
t . verbose = true
147
- t . options = "--profile" if ENV [ "CI " ]
167
+ t . options = "--profile" if ENV [ "BUILDKITE " ]
148
168
t . ruby_opts = [ "--dev" ] if defined? ( JRUBY_VERSION )
149
169
end
0 commit comments