Skip to content

Instantly share code, notes, and snippets.

@jasonong
Created April 29, 2010 07:10
Show Gist options
  • Save jasonong/383257 to your computer and use it in GitHub Desktop.
Save jasonong/383257 to your computer and use it in GitHub Desktop.
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