From 28f0e5c4fd146383686f6d552bcdcdd0c47e54aa Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 16 Jul 2014 21:11:48 -0500 Subject: [PATCH] Don't raise when converting the tag to a version fails --- Library/Homebrew/bottles.rb | 8 +++++++- Library/Homebrew/test/test_bottle_collector.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index cc29c54fda..0f5d36963e 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -114,10 +114,16 @@ class BottleCollector # so the same bottle can target multiple OSs. # Not used in core, used in taps. def find_or_later_tag(tag) + begin + tag_version = MacOS::Version.from_symbol(tag) + rescue ArgumentError + return + end + keys.find do |key| if key.to_s.end_with?("_or_later") later_tag = key.to_s[/(\w+)_or_later$/, 1].to_sym - MacOS::Version.from_symbol(later_tag) <= MacOS::Version.from_symbol(tag) + MacOS::Version.from_symbol(later_tag) <= tag_version end end end diff --git a/Library/Homebrew/test/test_bottle_collector.rb b/Library/Homebrew/test/test_bottle_collector.rb index 7a597404c5..34efe3efd1 100644 --- a/Library/Homebrew/test/test_bottle_collector.rb +++ b/Library/Homebrew/test/test_bottle_collector.rb @@ -20,6 +20,16 @@ class BottleCollectorTests < Homebrew::TestCase assert_nil checksum_for(:foo) end + def test_collector_returns_nil_for_no_match + @collector[:lion] = "foo" + assert_nil checksum_for(:foo) + end + + def test_collector_returns_nil_for_no_match_when_later_tag_present + @collector[:lion_or_later] = "foo" + 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)