Split out some Formula tests.
This commit is contained in:
parent
5cbab370e4
commit
31ebf6a293
@ -15,11 +15,6 @@ class MockFormula <Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class MostlyAbstractFormula <Formula
|
|
||||||
@url=''
|
|
||||||
@homepage = 'http://example.com/'
|
|
||||||
end
|
|
||||||
|
|
||||||
class TestZip <Formula
|
class TestZip <Formula
|
||||||
def initialize
|
def initialize
|
||||||
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
||||||
@ -30,14 +25,6 @@ class TestZip <Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestBallOverrideBrew <Formula
|
|
||||||
def initialize
|
|
||||||
super "foo"
|
|
||||||
end
|
|
||||||
def brew
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# All other tests so far -- feel free to break them out into
|
# All other tests so far -- feel free to break them out into
|
||||||
# separate TestCase classes.
|
# separate TestCase classes.
|
||||||
|
|
||||||
@ -52,15 +39,6 @@ class BeerTasting < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_prefix
|
|
||||||
nostdout do
|
|
||||||
TestBall.new.brew do |f|
|
|
||||||
assert_equal File.expand_path(f.prefix), (HOMEBREW_CELLAR+f.name+'0.1').to_s
|
|
||||||
assert_kind_of Pathname, f.prefix
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
FOOBAR='foo-bar'
|
FOOBAR='foo-bar'
|
||||||
def test_formula_funcs
|
def test_formula_funcs
|
||||||
classname=Formula.class_s(FOOBAR)
|
classname=Formula.class_s(FOOBAR)
|
||||||
@ -87,17 +65,6 @@ class BeerTasting < Test::Unit::TestCase
|
|||||||
assert_not_nil Formula.factory(FOOBAR)
|
assert_not_nil Formula.factory(FOOBAR)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cant_override_brew
|
|
||||||
assert_raises(RuntimeError) { TestBallOverrideBrew.new }
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_abstract_formula
|
|
||||||
f=MostlyAbstractFormula.new
|
|
||||||
assert_equal '__UNKNOWN__', f.name
|
|
||||||
assert_raises(RuntimeError) { f.prefix }
|
|
||||||
nostdout { assert_raises(RuntimeError) { f.brew } }
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_zip
|
def test_zip
|
||||||
nostdout { assert_nothing_raised { TestZip.new.brew {} } }
|
nostdout { assert_nothing_raised { TestZip.new.brew {} } }
|
||||||
end
|
end
|
||||||
@ -209,14 +176,6 @@ class BeerTasting < Test::Unit::TestCase
|
|||||||
assert_equal '0.1', foo1.version
|
assert_equal '0.1', foo1.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_naming
|
|
||||||
assert_equal 'ShellFm', Formula.class_s('shell.fm')
|
|
||||||
assert_equal 'Fooxx', Formula.class_s('foo++')
|
|
||||||
assert_equal 'SLang', Formula.class_s('s-lang')
|
|
||||||
assert_equal 'PkgConfig', Formula.class_s('pkg-config')
|
|
||||||
assert_equal 'FooBar', Formula.class_s('foo_bar')
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_ENV_options
|
def test_ENV_options
|
||||||
require 'extend/ENV'
|
require 'extend/ENV'
|
||||||
ENV.extend(HomebrewEnvExtension)
|
ENV.extend(HomebrewEnvExtension)
|
||||||
|
55
Library/Homebrew/test/test_formula.rb
Normal file
55
Library/Homebrew/test/test_formula.rb
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
require 'testing_env'
|
||||||
|
|
||||||
|
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
|
||||||
|
ARGV.extend(HomebrewArgvExtension)
|
||||||
|
|
||||||
|
require 'test/testball'
|
||||||
|
require 'utils'
|
||||||
|
require 'brew.h'
|
||||||
|
|
||||||
|
|
||||||
|
class MostlyAbstractFormula <Formula
|
||||||
|
@url=''
|
||||||
|
@homepage = 'http://example.com/'
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestBallOverrideBrew <Formula
|
||||||
|
def initialize
|
||||||
|
super "foo"
|
||||||
|
end
|
||||||
|
def brew
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
class FormulaTests < Test::Unit::TestCase
|
||||||
|
|
||||||
|
def test_prefix
|
||||||
|
nostdout do
|
||||||
|
TestBall.new.brew do |f|
|
||||||
|
assert_equal File.expand_path(f.prefix), (HOMEBREW_CELLAR+f.name+'0.1').to_s
|
||||||
|
assert_kind_of Pathname, f.prefix
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_class_naming
|
||||||
|
assert_equal 'ShellFm', Formula.class_s('shell.fm')
|
||||||
|
assert_equal 'Fooxx', Formula.class_s('foo++')
|
||||||
|
assert_equal 'SLang', Formula.class_s('s-lang')
|
||||||
|
assert_equal 'PkgConfig', Formula.class_s('pkg-config')
|
||||||
|
assert_equal 'FooBar', Formula.class_s('foo_bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_cant_override_brew
|
||||||
|
assert_raises(RuntimeError) { TestBallOverrideBrew.new }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_abstract_formula
|
||||||
|
f=MostlyAbstractFormula.new
|
||||||
|
assert_equal '__UNKNOWN__', f.name
|
||||||
|
assert_raises(RuntimeError) { f.prefix }
|
||||||
|
nostdout { assert_raises(RuntimeError) { f.brew } }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
# Feel free to split out test_bucket
|
# Feel free to split out test_bucket
|
||||||
ruby test_bucket.rb $*
|
ruby test_bucket.rb $*
|
||||||
|
ruby test_formula.rb $*
|
||||||
ruby test_versions.rb $*
|
ruby test_versions.rb $*
|
||||||
ruby test_checksums.rb $*
|
ruby test_checksums.rb $*
|
||||||
ruby test_inreplace.rb $*
|
ruby test_inreplace.rb $*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user