Method: Minitest::TestTask#define
- Defined in:
- lib/minitest/test_task.rb
#define ⇒ Object
:nodoc:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/minitest/test_task.rb', line 163 def define # :nodoc: desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args." task name do ruby make_test_cmd, verbose:verbose end desc "Print out the test command. Good for profiling and other tools." task "#{name}:cmd" do puts "ruby #{make_test_cmd}" end desc "Show which test files fail when run in isolation." task "#{name}:isolated" do tests = Dir[*self.test_globs].uniq # 3 seems to be the magic number... (tho not by that much) bad, good, n = {}, [], (ENV.delete("K") || 3).to_i file = ENV.delete("F") times = {} tt0 = Time.now n.threads_do tests.sort do |path| t0 = Time.now output = `#{Gem.ruby} #{make_test_cmd path} 2>&1` t1 = Time.now - t0 times[path] = t1 if $?.success? $stderr.print "." good << path else $stderr.print "x" bad[path] = output end end puts "done" puts "Ran in %.2f seconds" % [ Time.now - tt0 ] if file then require "json" File.open file, "w" do |io| io.puts JSON.pretty_generate times end end unless good.empty? puts puts "# Good tests:" puts good.sort.each do |path| puts "%.2fs: %s" % [times[path], path] end end unless bad.empty? puts puts "# Bad tests:" puts bad.keys.sort.each do |path| puts "%.2fs: %s" % [times[path], path] end puts puts "# Bad Test Output:" puts bad.sort.each do |path, output| puts puts "# #{path}:" puts output end exit 1 end end task "#{name}:deps" => "#{name}:isolated" # now just an alias desc "Show bottom 25 tests wrt time." task "#{name}:slow" do sh ["rake #{name} A=-v", "egrep '#test_.* s = .'", "sort -n -k2 -t=", "tail -25"].join " | " end end |