Refactor and clean up code
This commit is contained in:
parent
e2bc3c510e
commit
a5ca752658
@ -41,7 +41,7 @@ case hw_model
|
|||||||
#ENV['CFLAGS']="#{ENV['CFLAGS']} -march=nocona -msse3 -mmmx -m64"
|
#ENV['CFLAGS']="#{ENV['CFLAGS']} -march=nocona -msse3 -mmmx -m64"
|
||||||
#ENV['LDFLAGS']="-arch x86_64"
|
#ENV['LDFLAGS']="-arch x86_64"
|
||||||
|
|
||||||
when :xeon, :macpro
|
when :xeon
|
||||||
# TODO what optimisations for xeon?
|
# TODO what optimisations for xeon?
|
||||||
|
|
||||||
when :ppc then abort "Sorry, Homebrew does not support PowerPC architectures"
|
when :ppc then abort "Sorry, Homebrew does not support PowerPC architectures"
|
||||||
|
|||||||
@ -13,66 +13,44 @@ def hw_model
|
|||||||
when "iMac"
|
when "iMac"
|
||||||
if major <=4
|
if major <=4
|
||||||
:core1
|
:core1
|
||||||
elsif major <=8
|
|
||||||
:core2
|
|
||||||
else
|
else
|
||||||
$unknown_hw_model=true
|
$unknown_hw_model=true if major >8
|
||||||
:core2
|
:core2
|
||||||
end
|
end
|
||||||
|
|
||||||
when "MacBookAir"
|
when "MacBookAir"
|
||||||
if major <= 1
|
$unknown_hw_model=true if major > 1
|
||||||
:core2
|
:core2
|
||||||
else
|
|
||||||
$unknown_hw_model=true
|
|
||||||
:core2
|
|
||||||
end
|
|
||||||
|
|
||||||
when "MacBook"
|
when "MacBook"
|
||||||
if major <= 1
|
if major <= 1
|
||||||
:core1
|
:core1
|
||||||
elsif major <= 4
|
|
||||||
:core2
|
|
||||||
else
|
else
|
||||||
$unknown_hw_model=true
|
$unknown_hw_model=true if major > 4
|
||||||
:core2
|
:core2
|
||||||
end
|
end
|
||||||
|
|
||||||
when "MacBookPro"
|
when "MacBookPro"
|
||||||
if major <= 1
|
if major <= 1
|
||||||
:core1
|
:core1
|
||||||
elsif major <= 5
|
|
||||||
:core2
|
|
||||||
else
|
else
|
||||||
$unknown_hw_model=true
|
$unknown_hw_model=true if major > 5
|
||||||
:core2
|
:core2
|
||||||
end
|
end
|
||||||
|
|
||||||
when "Macmini" # Mac mini (Core Duo/Solo)
|
when "Macmini" # Mac mini (Core Duo/Solo)
|
||||||
if major <= 1
|
$unknown_hw_model=true if major > 1
|
||||||
:core
|
:core
|
||||||
else
|
|
||||||
$unknown_hw_model=true
|
|
||||||
:core
|
|
||||||
end
|
|
||||||
|
|
||||||
when "MacPro"
|
when "MacPro"
|
||||||
if major <= 3
|
$unknown_hw_model=true if major > 3
|
||||||
:xeon
|
:xeon
|
||||||
else
|
|
||||||
$unknown_hw_model=true
|
|
||||||
:xeon
|
|
||||||
end
|
|
||||||
|
|
||||||
when "PowerBook", "PowerMac", "RackMac" then :ppc
|
when "PowerBook", "PowerMac", "RackMac" then :ppc
|
||||||
|
|
||||||
when "Xserve"
|
when "Xserve"
|
||||||
if major <=2
|
$unknown_hw_model=true if major > 2
|
||||||
:xeon
|
:xeon
|
||||||
else
|
|
||||||
$unknown_hw_model=true
|
|
||||||
:xeon
|
|
||||||
end
|
|
||||||
|
|
||||||
when "ADP" then :dunno # Developer Transition Kit
|
when "ADP" then :dunno # Developer Transition Kit
|
||||||
when "M43ADP" then :dunno # Development Mac Pro
|
when "M43ADP" then :dunno # Development Mac Pro
|
||||||
|
|||||||
@ -19,10 +19,9 @@ at_exit { Pathname.new(HOMEBREW_CACHE).rmtree }
|
|||||||
require 'test/unit' # must be after at_exit
|
require 'test/unit' # must be after at_exit
|
||||||
|
|
||||||
|
|
||||||
class TestFormula <Formula
|
class MockFormula <Formula
|
||||||
def initialize url, md5='nomd5'
|
def initialize url
|
||||||
@url=url
|
@url=url
|
||||||
@md5=md5
|
|
||||||
super 'test'
|
super 'test'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -67,87 +66,87 @@ end
|
|||||||
|
|
||||||
class BeerTasting <Test::Unit::TestCase
|
class BeerTasting <Test::Unit::TestCase
|
||||||
def test_version_all_dots
|
def test_version_all_dots
|
||||||
r=TestFormula.new "http://example.com/foo.bar.la.1.14.zip"
|
r=MockFormula.new "http://example.com/foo.bar.la.1.14.zip"
|
||||||
assert_equal '1.14', r.version
|
assert_equal '1.14', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_underscore_separator
|
def test_version_underscore_separator
|
||||||
r=TestFormula.new "http://example.com/grc_1.1.tar.gz"
|
r=MockFormula.new "http://example.com/grc_1.1.tar.gz"
|
||||||
assert_equal '1.1', r.version
|
assert_equal '1.1', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_boost_version_style
|
def test_boost_version_style
|
||||||
r=TestFormula.new "http://example.com/boost_1_39_0.tar.bz2"
|
r=MockFormula.new "http://example.com/boost_1_39_0.tar.bz2"
|
||||||
assert_equal '1.39.0', r.version
|
assert_equal '1.39.0', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_erlang_version_style
|
def test_erlang_version_style
|
||||||
r=TestFormula.new "http://erlang.org/download/otp_src_R13B.tar.gz"
|
r=MockFormula.new "http://erlang.org/download/otp_src_R13B.tar.gz"
|
||||||
assert_equal 'R13B', r.version
|
assert_equal 'R13B', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_p7zip_version_style
|
def test_p7zip_version_style
|
||||||
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2"
|
r=MockFormula.new "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2"
|
||||||
assert_equal '9.04', r.version
|
assert_equal '9.04', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gloox_beta_style
|
def test_gloox_beta_style
|
||||||
r=TestFormula.new "http://camaya.net/download/gloox-1.0-beta7.tar.bz2"
|
r=MockFormula.new "http://camaya.net/download/gloox-1.0-beta7.tar.bz2"
|
||||||
assert_equal '1.0-beta7', r.version
|
assert_equal '1.0-beta7', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_astyle_verson_style
|
def test_astyle_verson_style
|
||||||
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
|
r=MockFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
|
||||||
assert_equal '1.23', r.version
|
assert_equal '1.23', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_libvorbis
|
def test_version_libvorbis
|
||||||
r=TestFormula.new "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2"
|
r=MockFormula.new "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2"
|
||||||
assert_equal '1.2.2rc1', r.version
|
assert_equal '1.2.2rc1', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dos2unix
|
def test_dos2unix
|
||||||
r=TestFormula.new "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz"
|
r=MockFormula.new "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz"
|
||||||
assert_equal '3.1', r.version
|
assert_equal '3.1', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_internal_dash
|
def test_version_internal_dash
|
||||||
r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz"
|
r=MockFormula.new "http://example.com/foo-arse-1.1-2.tar.gz"
|
||||||
assert_equal '1.1-2', r.version
|
assert_equal '1.1-2', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_single_digit
|
def test_version_single_digit
|
||||||
r=TestFormula.new "http://example.com/foo_bar.45.tar.gz"
|
r=MockFormula.new "http://example.com/foo_bar.45.tar.gz"
|
||||||
assert_equal '45', r.version
|
assert_equal '45', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_noseparator_single_digit
|
def test_noseparator_single_digit
|
||||||
r=TestFormula.new "http://example.com/foo_bar45.tar.gz"
|
r=MockFormula.new "http://example.com/foo_bar45.tar.gz"
|
||||||
assert_equal '45', r.version
|
assert_equal '45', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_developer_that_hates_us_format
|
def test_version_developer_that_hates_us_format
|
||||||
r=TestFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz"
|
r=MockFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz"
|
||||||
assert_equal '1.2.3', r.version
|
assert_equal '1.2.3', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version_regular
|
def test_version_regular
|
||||||
r=TestFormula.new "http://example.com/foo_bar-1.21.tar.gz"
|
r=MockFormula.new "http://example.com/foo_bar-1.21.tar.gz"
|
||||||
assert_equal '1.21', r.version
|
assert_equal '1.21', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_yet_another_version
|
def test_yet_another_version
|
||||||
r=TestFormula.new "http://example.com/mad-0.15.1b.tar.gz"
|
r=MockFormula.new "http://example.com/mad-0.15.1b.tar.gz"
|
||||||
assert_equal '0.15.1b', r.version
|
assert_equal '0.15.1b', r.version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_supported_compressed_types
|
def test_supported_compressed_types
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
TestFormula.new 'test-0.1.tar.gz'
|
MockFormula.new 'test-0.1.tar.gz'
|
||||||
TestFormula.new 'test-0.1.tar.bz2'
|
MockFormula.new 'test-0.1.tar.bz2'
|
||||||
TestFormula.new 'test-0.1.tgz'
|
MockFormula.new 'test-0.1.tgz'
|
||||||
TestFormula.new 'test-0.1.bgz'
|
MockFormula.new 'test-0.1.bgz'
|
||||||
TestFormula.new 'test-0.1.zip'
|
MockFormula.new 'test-0.1.zip'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user