#!/usr/bin/env ruby # suite.rb -- oddb -- 18.11.2002 -- hwyss@ywesee.com $: << File.dirname(__FILE__) require 'tempfile' directories = [] Dir.foreach(File.dirname(__FILE__)) { |dir| if /^test_.*/o.match(dir) directories << File.expand_path(dir, File.dirname(__FILE__)) end } #temp_out = [] temp_out = Tempfile.new('temp_out') directories.each { |dir| if(File.ftype(dir) == 'directory') puts dir Dir.foreach(dir) { |file| if /.*\.rb$/o.match(file) && file!='suite.rb' #require(File.expand_path(file, dir)) #full_path = File.expand_path(file, dir) full_path = File.join(dir, file) print "Now testting #{full_path}\n" #temp_out << %x{ruby #{full_path}} #system "ruby #{full_path} >> test.dat" system "ruby #{full_path} >> #{temp_out.path}" end } end } test_names = [] test_time = 0.0 tests = 0 assertions = 0 failures = 0 errors = 0 failure_error = [] failure_error_flag = false failure_error_no = 0 #temp_out.each do |line| #File.readlines('test.dat').each do |line| temp_out.each do |line| if line =~ /Loaded suite (.+)/ test_names << $1 end if line =~ /Finished in ([0-9.]+) seconds/ test_time += $1.to_f end if failure_error_flag failure_error << line end if line =~ /(\d+)\) Failure:/ or line =~ /(\d+)\) Error:/ failure_error_flag = true failure_error_no += 1 failure_error << line.gsub(/\d+/,failure_error_no.to_s) end if line.strip == '' failure_error_flag = false end if line =~ /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/ tests += $1.to_i assertions += $2.to_i failures += $3.to_i errors += $4.to_i end end # result print <<-EOF Loaded suite #{test_names.join(",\n ")} Finished in #{test_time} seconds. #{failure_error} #{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors EOF