Skip to content

Instantly share code, notes, and snippets.

@kevn
Created July 20, 2011 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevn/1095399 to your computer and use it in GitHub Desktop.
Save kevn/1095399 to your computer and use it in GitHub Desktop.
Run all tests matching wildcard args
#!/usr/bin/env ruby
require 'rubygems'
# Usage: run_tests user group network
pwd = Dir.pwd
finder_args = ARGV.map{|s| %Q(-name "*#{s}*_test.rb") }.join(' -or ')
test_paths = `find test -type d -maxdepth 1 -mindepth 1`.split("\n")
test_paths.each do |path|
tests = `find #{path} #{finder_args}`.split("\n")
if tests.any?
puts "=== #{path} ==="
rake_path = Gem.source_index.detect{|name, spec| name =~ /^rake-/ }[1].full_gem_path
cmd = %Q(ruby -I"lib:test" "#{rake_path}/lib/rake/rake_test_loader.rb" #{tests.join(' ')})
puts cmd
system cmd
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment