Created
April 29, 2010 07:10
-
-
Save jasonong/383257 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
namespace :unittest do | |
task *[:tag, (0..100).map {|i| "t#{i}".to_sym }].flatten do |t, args| | |
args.each do |key, value| | |
Dir[File.join(RAILS_ROOT, 'test', 'unit', '*.rb')].each do |file| | |
File.open(file,'r') do |fh| | |
tags = fh.grep(/\~(\S+)/).map do |t| | |
t.strip! | |
t.split(/\s+/) | |
end | |
@tagged_file_cache ||= {} | |
[tags].flatten.each do |tag| | |
next if tag == "#" | |
tagged = tag[/\~(\S+)$/,1] | |
if value == tagged | |
tag = tagged && tagged.to_sym | |
@tagged_file_cache[tag] ||= [] | |
@tagged_file_cache[tag] << file unless @tagged_file_cache[tag].include?(file) | |
end | |
end | |
end | |
end | |
end | |
@tagged_file_cache.each do |symb, files| | |
files.each do |file| | |
system "ruby #{file}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment