Skip to content
Snippets Groups Projects
Commit 2122620d authored by Jack Nagel's avatar Jack Nagel
Browse files

Fix `brew test` when conflicting minitest gems are installed

parent ea203c2a
No related branches found
No related tags found
No related merge requests found
......@@ -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 }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment