aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/Rakefile
blob: cfb3d7d97c83b7e77f7e4487408ac3a338c2aee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'rake'
require 'rake/testtask'
require 'pathname'

TEST_DIRECTORY = Pathname.new(File.expand_path(__FILE__)).parent.realpath
TEST_FILES = FileList["#{TEST_DIRECTORY}/test_*.rb"]
GEM_DEPS = ['mocha']

Dir.chdir(TEST_DIRECTORY)

task :default => :test

task :deps do
  GEM_DEPS.each do |dep|
    `gem list --installed #{dep}`
    next if $?.success?
    sh 'gem', 'install', '--no-ri', '--no-rdoc', '--user-install', dep
  end
end

Rake::TestTask.new(:test) do |t|
  t.libs << Dir.pwd
  t.test_files = TEST_FILES
end

namespace :test do
  TEST_FILES.each do |file|
    task = /test_(.+)\.rb/.match(file)
    Rake::TestTask.new(task[1]) do |t|
      t.libs << Dir.pwd
      t.pattern = task[0]
    end
  end
end

begin
  require 'rubygems'
  require 'rcov/rcovtask'

  Rcov::RcovTask.new do |t|
    t.libs << Dir.pwd
    t.test_files = TEST_FILES
    t.rcov_opts = %w{--exclude=Gems
                     --exclude=test_
                     --exclude=testball
                     --exclude=testing}
    t.output_dir = TEST_DIRECTORY+'coverage'
  end
rescue LoadError
end

begin
  require 'rubygems'
  require 'ruby-prof/task'

  RubyProf::ProfileTask.new do |t|
    t.libs << Dir.pwd
    t.test_files = TEST_FILES
    t.output_dir = TEST_DIRECTORY+'prof'
    t.printer = :graph_html
    t.min_percent = 2
  end
rescue LoadError
end