mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Move assertion setup into formula_assertions.rb
This commit is contained in:
parent
b61528e757
commit
4bdfb27d9f
@ -1,33 +1,11 @@
|
||||
require "extend/ENV"
|
||||
require "timeout"
|
||||
require "debrew"
|
||||
require "formula_assertions"
|
||||
|
||||
module Homebrew
|
||||
TEST_TIMEOUT_SECONDS = 5*60
|
||||
|
||||
if defined?(Gem)
|
||||
begin
|
||||
gem "minitest", "< 5.0.0"
|
||||
rescue Gem::LoadError
|
||||
require "test/unit/assertions"
|
||||
else
|
||||
require "minitest/unit"
|
||||
require "test/unit/assertions"
|
||||
end
|
||||
else
|
||||
require "test/unit/assertions"
|
||||
end
|
||||
|
||||
if defined?(MiniTest::Assertion)
|
||||
FailedAssertion = MiniTest::Assertion
|
||||
elsif defined?(Minitest::Assertion)
|
||||
FailedAssertion = Minitest::Assertion
|
||||
else
|
||||
FailedAssertion = Test::Unit::AssertionFailedError
|
||||
end
|
||||
|
||||
require "formula_assertions"
|
||||
|
||||
def test
|
||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||
|
||||
@ -49,8 +27,7 @@ module Homebrew
|
||||
|
||||
puts "Testing #{f.name}"
|
||||
|
||||
f.extend(Test::Unit::Assertions)
|
||||
f.extend(Homebrew::Assertions)
|
||||
f.extend(Assertions)
|
||||
f.extend(Debrew::Formula) if ARGV.debug?
|
||||
|
||||
env = ENV.to_hash
|
||||
@ -60,7 +37,7 @@ module Homebrew
|
||||
Timeout::timeout TEST_TIMEOUT_SECONDS do
|
||||
raise if f.run_test == false
|
||||
end
|
||||
rescue FailedAssertion => e
|
||||
rescue Assertions::FailedAssertion => e
|
||||
ofail "#{f.name}: failed"
|
||||
puts e.message
|
||||
rescue Exception => e
|
||||
|
@ -1,7 +1,26 @@
|
||||
require 'test/unit/assertions'
|
||||
|
||||
module Homebrew
|
||||
module Assertions
|
||||
if defined?(Gem)
|
||||
begin
|
||||
gem "minitest", "< 5.0.0"
|
||||
rescue Gem::LoadError
|
||||
require "test/unit/assertions"
|
||||
else
|
||||
require "minitest/unit"
|
||||
require "test/unit/assertions"
|
||||
end
|
||||
else
|
||||
require "test/unit/assertions"
|
||||
end
|
||||
|
||||
if defined?(MiniTest::Assertion)
|
||||
FailedAssertion = MiniTest::Assertion
|
||||
elsif defined?(Minitest::Assertion)
|
||||
FailedAssertion = Minitest::Assertion
|
||||
else
|
||||
FailedAssertion = Test::Unit::AssertionFailedError
|
||||
end
|
||||
|
||||
include Test::Unit::Assertions
|
||||
|
||||
# Returns the output of running cmd, and asserts the exit status
|
||||
|
Loading…
x
Reference in New Issue
Block a user