From 541e8f28df7f8d7a21f976e669190a32fe88473e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 16 Jul 2016 21:06:30 +0100 Subject: bottles: more porting to generic layer. --- ...stball_bottle-0.1.macintosh_intel.bottle.tar.gz | 1 + Library/Homebrew/test/test_bottle_collector.rb | 14 ---- Library/Homebrew/test/test_bottle_tag.rb | 79 ---------------------- .../Homebrew/test/test_os_mac_bottle_collector.rb | 26 +++++++ Library/Homebrew/test/test_os_mac_bottle_tag.rb | 79 ++++++++++++++++++++++ Library/Homebrew/utils/bottles.rb | 2 +- 6 files changed, 107 insertions(+), 94 deletions(-) create mode 120000 Library/Homebrew/test/bottles/testball_bottle-0.1.macintosh_intel.bottle.tar.gz delete mode 100644 Library/Homebrew/test/test_bottle_tag.rb create mode 100644 Library/Homebrew/test/test_os_mac_bottle_collector.rb create mode 100644 Library/Homebrew/test/test_os_mac_bottle_tag.rb (limited to 'Library') diff --git a/Library/Homebrew/test/bottles/testball_bottle-0.1.macintosh_intel.bottle.tar.gz b/Library/Homebrew/test/bottles/testball_bottle-0.1.macintosh_intel.bottle.tar.gz new file mode 120000 index 000000000..3e989830b --- /dev/null +++ b/Library/Homebrew/test/bottles/testball_bottle-0.1.macintosh_intel.bottle.tar.gz @@ -0,0 +1 @@ +testball_bottle-0.1.yosemite.bottle.tar.gz \ No newline at end of file diff --git a/Library/Homebrew/test/test_bottle_collector.rb b/Library/Homebrew/test/test_bottle_collector.rb index fa356cb93..d75e29ec8 100644 --- a/Library/Homebrew/test/test_bottle_collector.rb +++ b/Library/Homebrew/test/test_bottle_collector.rb @@ -30,23 +30,9 @@ class BottleCollectorTests < Homebrew::TestCase assert_nil checksum_for(:foo) end - def test_collector_finds_or_later_tags - @collector[:lion_or_later] = "foo" - assert_equal ["foo", :lion_or_later], checksum_for(:mountain_lion) - assert_nil checksum_for(:snow_leopard) - end - def test_collector_prefers_exact_matches @collector[:lion_or_later] = "foo" @collector[:mountain_lion] = "bar" assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion) end - - def test_collector_finds_altivec_tags - @collector[:tiger_altivec] = "foo" - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4) - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4e) - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g5) - assert_nil checksum_for(:tiger_g3) - end end diff --git a/Library/Homebrew/test/test_bottle_tag.rb b/Library/Homebrew/test/test_bottle_tag.rb deleted file mode 100644 index 174c7d14e..000000000 --- a/Library/Homebrew/test/test_bottle_tag.rb +++ /dev/null @@ -1,79 +0,0 @@ -require "testing_env" -require "utils/bottles" - -class BottleTagTests < Homebrew::TestCase - def test_tag_tiger_ppc - MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) - Hardware::CPU.stubs(:type).returns(:ppc) - Hardware::CPU.stubs(:family).returns(:foo) - MacOS.stubs(:prefer_64_bit?).returns(false) - assert_equal :tiger_foo, Utils::Bottles.tag - end - - def test_tag_tiger_intel - MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) - Hardware::CPU.stubs(:type).returns(:intel) - MacOS.stubs(:prefer_64_bit?).returns(false) - assert_equal :tiger, Utils::Bottles.tag - end - - def test_tag_tiger_ppc_64 - MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) - Hardware::CPU.stubs(:type).returns(:ppc) - Hardware::CPU.stubs(:family).returns(:g5) - MacOS.stubs(:prefer_64_bit?).returns(true) - assert_equal :tiger_g5_64, Utils::Bottles.tag - end - - # Note that this will probably never be used - def test_tag_tiger_intel_64 - MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) - Hardware::CPU.stubs(:type).returns(:intel) - MacOS.stubs(:prefer_64_bit?).returns(true) - assert_equal :tiger_64, Utils::Bottles.tag - end - - def test_tag_leopard_intel - MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) - Hardware::CPU.stubs(:type).returns(:intel) - MacOS.stubs(:prefer_64_bit?).returns(false) - assert_equal :leopard, Utils::Bottles.tag - end - - def test_tag_leopard_ppc_64 - MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) - Hardware::CPU.stubs(:type).returns(:ppc) - Hardware::CPU.stubs(:family).returns(:g5) - MacOS.stubs(:prefer_64_bit?).returns(true) - assert_equal :leopard_g5_64, Utils::Bottles.tag - end - - def test_tag_leopard_intel_64 - MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) - Hardware::CPU.stubs(:type).returns(:intel) - MacOS.stubs(:prefer_64_bit?).returns(true) - assert_equal :leopard_64, Utils::Bottles.tag - end - - def test_tag_snow_leopard_32 - MacOS.stubs(:version).returns(MacOS::Version.new("10.6")) - Hardware::CPU.stubs(:is_64_bit?).returns(false) - assert_equal :snow_leopard_32, Utils::Bottles.tag - end - - def test_tag_snow_leopard_64 - MacOS.stubs(:version).returns(MacOS::Version.new("10.6")) - Hardware::CPU.stubs(:is_64_bit?).returns(true) - assert_equal :snow_leopard, Utils::Bottles.tag - end - - def test_tag_lion - MacOS.stubs(:version).returns(MacOS::Version.new("10.7")) - assert_equal :lion, Utils::Bottles.tag - end - - def test_tag_mountain_lion - MacOS.stubs(:version).returns(MacOS::Version.new("10.8")) - assert_equal :mountain_lion, Utils::Bottles.tag - end -end diff --git a/Library/Homebrew/test/test_os_mac_bottle_collector.rb b/Library/Homebrew/test/test_os_mac_bottle_collector.rb new file mode 100644 index 000000000..2f88050ae --- /dev/null +++ b/Library/Homebrew/test/test_os_mac_bottle_collector.rb @@ -0,0 +1,26 @@ +require "testing_env" +require "utils/bottles" + +class OSMacBottleCollectorTests < Homebrew::TestCase + def setup + @collector = Utils::Bottles::Collector.new + end + + def checksum_for(tag) + @collector.fetch_checksum_for(tag) + end + + def test_collector_finds_or_later_tags + @collector[:lion_or_later] = "foo" + assert_equal ["foo", :lion_or_later], checksum_for(:mountain_lion) + assert_nil checksum_for(:snow_leopard) + end + + def test_collector_finds_altivec_tags + @collector[:tiger_altivec] = "foo" + assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4) + assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4e) + assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g5) + assert_nil checksum_for(:tiger_g3) + end +end diff --git a/Library/Homebrew/test/test_os_mac_bottle_tag.rb b/Library/Homebrew/test/test_os_mac_bottle_tag.rb new file mode 100644 index 000000000..996bd4d53 --- /dev/null +++ b/Library/Homebrew/test/test_os_mac_bottle_tag.rb @@ -0,0 +1,79 @@ +require "testing_env" +require "utils/bottles" + +class OSMacBottleTagTests < Homebrew::TestCase + def test_tag_tiger_ppc + MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) + Hardware::CPU.stubs(:type).returns(:ppc) + Hardware::CPU.stubs(:family).returns(:foo) + MacOS.stubs(:prefer_64_bit?).returns(false) + assert_equal :tiger_foo, Utils::Bottles.tag + end + + def test_tag_tiger_intel + MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) + Hardware::CPU.stubs(:type).returns(:intel) + MacOS.stubs(:prefer_64_bit?).returns(false) + assert_equal :tiger, Utils::Bottles.tag + end + + def test_tag_tiger_ppc_64 + MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) + Hardware::CPU.stubs(:type).returns(:ppc) + Hardware::CPU.stubs(:family).returns(:g5) + MacOS.stubs(:prefer_64_bit?).returns(true) + assert_equal :tiger_g5_64, Utils::Bottles.tag + end + + # Note that this will probably never be used + def test_tag_tiger_intel_64 + MacOS.stubs(:version).returns(MacOS::Version.new("10.4")) + Hardware::CPU.stubs(:type).returns(:intel) + MacOS.stubs(:prefer_64_bit?).returns(true) + assert_equal :tiger_64, Utils::Bottles.tag + end + + def test_tag_leopard_intel + MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) + Hardware::CPU.stubs(:type).returns(:intel) + MacOS.stubs(:prefer_64_bit?).returns(false) + assert_equal :leopard, Utils::Bottles.tag + end + + def test_tag_leopard_ppc_64 + MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) + Hardware::CPU.stubs(:type).returns(:ppc) + Hardware::CPU.stubs(:family).returns(:g5) + MacOS.stubs(:prefer_64_bit?).returns(true) + assert_equal :leopard_g5_64, Utils::Bottles.tag + end + + def test_tag_leopard_intel_64 + MacOS.stubs(:version).returns(MacOS::Version.new("10.5")) + Hardware::CPU.stubs(:type).returns(:intel) + MacOS.stubs(:prefer_64_bit?).returns(true) + assert_equal :leopard_64, Utils::Bottles.tag + end + + def test_tag_snow_leopard_32 + MacOS.stubs(:version).returns(MacOS::Version.new("10.6")) + Hardware::CPU.stubs(:is_64_bit?).returns(false) + assert_equal :snow_leopard_32, Utils::Bottles.tag + end + + def test_tag_snow_leopard_64 + MacOS.stubs(:version).returns(MacOS::Version.new("10.6")) + Hardware::CPU.stubs(:is_64_bit?).returns(true) + assert_equal :snow_leopard, Utils::Bottles.tag + end + + def test_tag_lion + MacOS.stubs(:version).returns(MacOS::Version.new("10.7")) + assert_equal :lion, Utils::Bottles.tag + end + + def test_tag_mountain_lion + MacOS.stubs(:version).returns(MacOS::Version.new("10.8")) + assert_equal :mountain_lion, Utils::Bottles.tag + end +end diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 8447f2472..7b40a2e41 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -5,7 +5,7 @@ module Utils class Bottles class << self def tag - @bottle_tag ||= "#{ENV["HOMEBREW_SYSTEM"]}-#{ENV["HOMEBREW_PROCESSOR"]}".downcase.to_sym + @bottle_tag ||= "#{ENV["HOMEBREW_SYSTEM"]}_#{ENV["HOMEBREW_PROCESSOR"]}".downcase.to_sym end def built_as?(f) -- cgit v1.2.3