Created
June 7, 2012 15:08
-
-
Save thomasjachmann/2889301 to your computer and use it in GitHub Desktop.
run failing tests from a test/unit output (eg from rake test:units > units.txt)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_support/inflector" | |
TESTDEF_REGEX = %r|^([a-z_]+)\(([a-zA-Z]+)\)| | |
test_methods = [] | |
test_files = [] | |
arg = ARGV.shift | |
if match = arg.strip.match(TESTDEF_REGEX) | |
test_methods << match[1] | |
test_files = Dir.glob("test/**/#{match[2].underscore}.rb").map {|f| f[0..-4]} | |
else | |
test_method = nil | |
IO.readlines(arg).each do |line| | |
if match = line.match(TESTDEF_REGEX) | |
test_methods << test_method = match[1] | |
elsif test_method && match = line.match(%r|^[ \[]+/(.*)\.rb:[0-9]+:in `#{test_method}'|) | |
test_files << match[1] | |
test_method = nil | |
end | |
end | |
test_files.uniq! | |
end | |
puts "running #{test_methods.size} tests in #{test_files.size} files" | |
ARGV << "-n" | |
ARGV << "/#{test_methods.join("|")}/" | |
test_files.each do |test_file| | |
require test_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment