Fix brew test when conflicting minitest gems are installed
This commit is contained in:
parent
ea203c2aac
commit
2122620d71
@ -2,16 +2,23 @@ require 'extend/ENV'
|
||||
require 'hardware'
|
||||
require 'keg'
|
||||
require 'timeout'
|
||||
require 'test/unit/assertions'
|
||||
|
||||
module Homebrew extend self
|
||||
TEST_TIMEOUT_SECONDS = 5*60
|
||||
|
||||
if Object.const_defined?(:Minitest)
|
||||
FailedAssertion = Minitest::Assertion
|
||||
elsif Object.const_defined?(:MiniTest)
|
||||
FailedAssertion = MiniTest::Assertion
|
||||
if defined?(Gem)
|
||||
begin
|
||||
gem "minitest", "< 5.0.0"
|
||||
rescue Gem::LoadError
|
||||
require "test/unit/assertions"
|
||||
FailedAssertion = Test::Unit::AssertionFailedError
|
||||
else
|
||||
require "minitest/unit"
|
||||
require "test/unit/assertions"
|
||||
FailedAssertion = MiniTest::Assertion
|
||||
end
|
||||
else
|
||||
require "test/unit/assertions"
|
||||
FailedAssertion = Test::Unit::AssertionFailedError
|
||||
end
|
||||
|
||||
@ -35,6 +42,9 @@ module Homebrew extend self
|
||||
end
|
||||
|
||||
puts "Testing #{f.name}"
|
||||
|
||||
f.extend(Test::Unit::Assertions)
|
||||
|
||||
begin
|
||||
# tests can also return false to indicate failure
|
||||
Timeout::timeout TEST_TIMEOUT_SECONDS do
|
||||
|
||||
@ -491,8 +491,6 @@ class Formula
|
||||
end
|
||||
|
||||
def test
|
||||
require 'test/unit/assertions'
|
||||
extend(Test::Unit::Assertions)
|
||||
# Adding the used options allows us to use `build.with?` inside of tests
|
||||
tab = Tab.for_name(name)
|
||||
tab.used_options.each { |opt| build.args << opt unless build.has_opposite_of? opt }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user