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 "extend/ENV"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
require "debrew"
|
require "debrew"
|
||||||
|
require "formula_assertions"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
TEST_TIMEOUT_SECONDS = 5*60
|
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
|
def test
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
@ -49,8 +27,7 @@ module Homebrew
|
|||||||
|
|
||||||
puts "Testing #{f.name}"
|
puts "Testing #{f.name}"
|
||||||
|
|
||||||
f.extend(Test::Unit::Assertions)
|
f.extend(Assertions)
|
||||||
f.extend(Homebrew::Assertions)
|
|
||||||
f.extend(Debrew::Formula) if ARGV.debug?
|
f.extend(Debrew::Formula) if ARGV.debug?
|
||||||
|
|
||||||
env = ENV.to_hash
|
env = ENV.to_hash
|
||||||
@ -60,7 +37,7 @@ module Homebrew
|
|||||||
Timeout::timeout TEST_TIMEOUT_SECONDS do
|
Timeout::timeout TEST_TIMEOUT_SECONDS do
|
||||||
raise if f.run_test == false
|
raise if f.run_test == false
|
||||||
end
|
end
|
||||||
rescue FailedAssertion => e
|
rescue Assertions::FailedAssertion => e
|
||||||
ofail "#{f.name}: failed"
|
ofail "#{f.name}: failed"
|
||||||
puts e.message
|
puts e.message
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -1,7 +1,26 @@
|
|||||||
require 'test/unit/assertions'
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Assertions
|
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
|
include Test::Unit::Assertions
|
||||||
|
|
||||||
# Returns the output of running cmd, and asserts the exit status
|
# Returns the output of running cmd, and asserts the exit status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user