2012-03-12 21:21:33 -07:00
|
|
|
require 'extend/ENV'
|
|
|
|
require 'hardware'
|
|
|
|
require 'keg'
|
2013-06-04 20:34:34 +01:00
|
|
|
require 'timeout'
|
2012-03-12 21:21:33 -07:00
|
|
|
|
2011-03-10 21:28:49 -08:00
|
|
|
module Homebrew extend self
|
2013-06-04 20:34:34 +01:00
|
|
|
TEST_TIMEOUT_SECONDS = 5*60
|
|
|
|
|
2011-03-10 21:28:49 -08:00
|
|
|
def test
|
2012-04-20 13:56:51 -05:00
|
|
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
2012-02-04 00:01:29 -06:00
|
|
|
|
2012-09-11 14:47:06 -05:00
|
|
|
ENV.extend(HomebrewEnvExtension)
|
|
|
|
ENV.setup_build_environment
|
|
|
|
|
2011-03-10 21:28:49 -08:00
|
|
|
ARGV.formulae.each do |f|
|
|
|
|
# Cannot test uninstalled formulae
|
|
|
|
unless f.installed?
|
2012-04-30 14:08:59 +10:00
|
|
|
ofail "Testing requires the latest version of #{f.name}"
|
2011-03-10 21:28:49 -08:00
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
# Cannot test formulae without a test method
|
2013-01-07 17:34:56 -06:00
|
|
|
unless f.test_defined?
|
2012-04-30 14:08:59 +10:00
|
|
|
ofail "#{f.name} defines no test"
|
2011-03-10 21:28:49 -08:00
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Testing #{f.name}"
|
|
|
|
begin
|
2012-02-18 21:32:31 -06:00
|
|
|
# tests can also return false to indicate failure
|
2013-06-04 20:34:34 +01:00
|
|
|
Timeout::timeout TEST_TIMEOUT_SECONDS do
|
|
|
|
raise if f.test == false
|
|
|
|
end
|
|
|
|
rescue Exception
|
2012-04-30 14:08:59 +10:00
|
|
|
ofail "#{f.name}: failed"
|
2011-03-10 21:28:49 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|