'brew tests' optional coverage measure added

Closes Homebrew/homebrew#41890.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-07-19 10:29:40 +02:00
parent 9877b1e7b8
commit 44a8ebdc7e
5 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@
/Library/Homebrew/test/.bundle /Library/Homebrew/test/.bundle
/Library/Homebrew/test/bin /Library/Homebrew/test/bin
/Library/Homebrew/test/vendor /Library/Homebrew/test/vendor
/Library/Homebrew/test/coverage
/Library/LinkedKegs /Library/LinkedKegs
/Library/PinnedKegs /Library/PinnedKegs
/Library/Taps /Library/Taps

View File

@ -2,6 +2,7 @@ module Homebrew
def tests def tests
(HOMEBREW_LIBRARY/"Homebrew/test").cd do (HOMEBREW_LIBRARY/"Homebrew/test").cd do
ENV["TESTOPTS"] = "-v" if ARGV.verbose? ENV["TESTOPTS"] = "-v" if ARGV.verbose?
ENV["HOMEBREW_TESTS_COVERAGE"] = "1" if ARGV.flag? "--coverage"
Homebrew.install_gem_setup_path! "bundler" Homebrew.install_gem_setup_path! "bundler"
quiet_system("bundle", "check") || \ quiet_system("bundle", "check") || \
system("bundle", "install", "--path", "vendor/bundle") system("bundle", "install", "--path", "vendor/bundle")

View File

@ -3,3 +3,4 @@ source "https://rubygems.org"
gem "mocha", "~> 1.1" gem "mocha", "~> 1.1"
gem "minitest", "~> 5.3" gem "minitest", "~> 5.3"
gem "rake", "~> 10.3" gem "rake", "~> 10.3"
gem "simplecov", "~> 0.10.0", :require => false

View File

@ -1,11 +1,18 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
docile (1.1.5)
json (1.8.3)
metaclass (0.0.4) metaclass (0.0.4)
minitest (5.7.0) minitest (5.7.0)
mocha (1.1.0) mocha (1.1.0)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
rake (10.4.2) rake (10.4.2)
simplecov (0.10.0)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
PLATFORMS PLATFORMS
ruby ruby
@ -14,3 +21,4 @@ DEPENDENCIES
minitest (~> 5.3) minitest (~> 5.3)
mocha (~> 1.1) mocha (~> 1.1)
rake (~> 10.3) rake (~> 10.3)
simplecov (~> 0.10.0)

View File

@ -1,6 +1,22 @@
$:.unshift File.expand_path("../..", __FILE__) $:.unshift File.expand_path("../..", __FILE__)
$:.unshift File.expand_path("../lib", __FILE__) $:.unshift File.expand_path("../lib", __FILE__)
# This must be at the top
if ENV["HOMEBREW_TESTS_COVERAGE"]
require "simplecov"
SimpleCov.start do
tests_path = File.dirname(__FILE__)
minimum_coverage 50
coverage_dir File.expand_path("#{tests_path}/coverage")
root File.expand_path("#{tests_path}/..")
add_filter "Homebrew/test"
add_filter "vendor/bundle"
add_filter "Homebrew/vendor"
end
end
require "global" require "global"
# Test environment setup # Test environment setup