tests: support "rake rcov" if rcov is installed
If the rcov gem is installed, `rake rcov` will generate a test coverage report in the coverage directory. I picked rcov because it is 1.8 compatible. But it could easily be swapped out for another coverage tool. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
8abfee7d9c
commit
b7bdd2f578
1
Library/Homebrew/test/.gitignore
vendored
Normal file
1
Library/Homebrew/test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/coverage
|
||||
@ -1,9 +1,10 @@
|
||||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
|
||||
Dir.chdir File.expand_path(File.dirname(__FILE__))
|
||||
TEST_DIRECTORY = File.expand_path(File.dirname(__FILE__))
|
||||
TEST_FILES = FileList["#{TEST_DIRECTORY}/test_*.rb"]
|
||||
|
||||
TEST_FILES = FileList['test_*.rb']
|
||||
Dir.chdir TEST_DIRECTORY
|
||||
|
||||
task :default => :test
|
||||
|
||||
@ -21,3 +22,20 @@ namespace :test do
|
||||
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
|
||||
nil
|
||||
end
|
||||
|
||||
@ -25,8 +25,13 @@ HOMEBREW_CURL_ARGS = '-fsLA'
|
||||
MACOS_VERSION=10.6
|
||||
|
||||
(HOMEBREW_PREFIX+'Library/Formula').mkpath
|
||||
|
||||
prevwd = Dir.pwd
|
||||
Dir.chdir HOMEBREW_PREFIX
|
||||
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||
at_exit do
|
||||
Dir.chdir prevwd
|
||||
HOMEBREW_PREFIX.parent.rmtree
|
||||
end
|
||||
|
||||
# Test fixtures and files can be found relative to this path
|
||||
TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user