diff options
| author | Jack Nagel | 2012-06-16 11:35:02 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2012-06-16 11:43:43 -0500 | 
| commit | 2cca8e1a4f538aa7c2316752e21a26f1d490f107 (patch) | |
| tree | 7bdbadc38f3bab3eb5a21a54f0e05fabc5713b3c /Library/Homebrew/test/test_mach.rb | |
| parent | 075a59e3f11d71afc43b223436a593e31640770e (diff) | |
| download | brew-2cca8e1a4f538aa7c2316752e21a26f1d490f107.tar.bz2 | |
Teach Mach-O machinery about bundles
c.f. Homebrew/homebrew#12810.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/test/test_mach.rb')
| -rw-r--r-- | Library/Homebrew/test/test_mach.rb | 74 | 
1 files changed, 59 insertions, 15 deletions
diff --git a/Library/Homebrew/test/test_mach.rb b/Library/Homebrew/test/test_mach.rb index a0efb6928..b9acd337f 100644 --- a/Library/Homebrew/test/test_mach.rb +++ b/Library/Homebrew/test/test_mach.rb @@ -3,6 +3,10 @@ require 'testing_env'  require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser  ARGV.extend(HomebrewArgvExtension) +def file pn +  `/usr/bin/file -h '#{pn}'`.chomp +end +  class MachOPathnameTests < Test::Unit::TestCase    def test_fat_dylib      pn = Pathname.new("#{TEST_FOLDER}/mach/fat.dylib") @@ -15,8 +19,7 @@ class MachOPathnameTests < Test::Unit::TestCase      assert !pn.mach_o_executable?      assert !pn.text_executable?      assert pn.arch == :universal -    assert_match /Mach-O (64-bit )?dynamically linked shared library/, -      `/usr/bin/file -h '#{pn}'`.chomp +    assert_match /Mach-O (64-bit )?dynamically linked shared library/, file(pn)    end    def test_i386_dylib @@ -29,8 +32,8 @@ class MachOPathnameTests < Test::Unit::TestCase      assert pn.dylib?      assert !pn.mach_o_executable?      assert !pn.text_executable? -    assert_match /Mach-O (64-bit )?dynamically linked shared library/, -      `/usr/bin/file -h '#{pn}'`.chomp +    assert !pn.mach_o_bundle? +    assert_match /Mach-O dynamically linked shared library/, file(pn)    end    def test_x86_64_dylib @@ -43,8 +46,8 @@ class MachOPathnameTests < Test::Unit::TestCase      assert pn.dylib?      assert !pn.mach_o_executable?      assert !pn.text_executable? -    assert_match /Mach-O (64-bit )?dynamically linked shared library/, -      `/usr/bin/file -h '#{pn}'`.chomp +    assert !pn.mach_o_bundle? +    assert_match /Mach-O 64-bit dynamically linked shared library/, file(pn)    end    def test_mach_o_executable @@ -57,8 +60,50 @@ class MachOPathnameTests < Test::Unit::TestCase      assert !pn.dylib?      assert pn.mach_o_executable?      assert !pn.text_executable? -    assert_match /Mach-O (64-bit )?executable/, -      `/usr/bin/file -h '#{pn}'`.chomp +    assert !pn.mach_o_bundle? +    assert_match /Mach-O (64-bit )?executable/, file(pn) +  end + +  def test_fat_bundle +    pn = Pathname.new("#{TEST_FOLDER}/mach/fat.bundle") +    assert pn.universal? +    assert !pn.i386? +    assert !pn.x86_64? +    assert !pn.ppc7400? +    assert !pn.ppc64? +    assert !pn.dylib? +    assert !pn.mach_o_executable? +    assert !pn.text_executable? +    assert pn.mach_o_bundle? +    assert_match /Mach-O (64-bit )?bundle/, file(pn) +  end + +  def test_i386_bundle +    pn = Pathname.new("#{TEST_FOLDER}/mach/i386.bundle") +    assert !pn.universal? +    assert pn.i386? +    assert !pn.x86_64? +    assert !pn.ppc7400? +    assert !pn.ppc64? +    assert !pn.dylib? +    assert !pn.mach_o_executable? +    assert !pn.text_executable? +    assert pn.mach_o_bundle? +    assert_match /Mach-O bundle/, file(pn) +  end + +  def test_x86_64_bundle +    pn = Pathname.new("#{TEST_FOLDER}/mach/x86_64.bundle") +    assert !pn.universal? +    assert !pn.i386? +    assert pn.x86_64? +    assert !pn.ppc7400? +    assert !pn.ppc64? +    assert !pn.dylib? +    assert !pn.mach_o_executable? +    assert !pn.text_executable? +    assert pn.mach_o_bundle? +    assert_match /Mach-O 64-bit bundle/, file(pn)    end    def test_non_mach_o @@ -71,11 +116,10 @@ class MachOPathnameTests < Test::Unit::TestCase      assert !pn.dylib?      assert !pn.mach_o_executable?      assert !pn.text_executable? +    assert !pn.mach_o_bundle?      assert pn.arch == :dunno -    assert_no_match /Mach-O (64-bit )?dynamically linked shared library/, -      `/usr/bin/file -h '#{pn}'`.chomp -    assert_no_match /Mach-O [^ ]* ?executable/, -      `/usr/bin/file -h '#{pn}'`.chomp +    assert_no_match /Mach-O (64-bit )?dynamically linked shared library/, file(pn) +    assert_no_match /Mach-O [^ ]* ?executable/, file(pn)    end    def test_architecture_list_extension @@ -114,7 +158,7 @@ class TextExecutableTests < Test::Unit::TestCase      assert pn.text_executable?      assert_equal [], pn.archs      assert pn.arch == :dunno -    assert_match /text executable/, `/usr/bin/file -h '#{pn}'`.chomp +    assert_match /text executable/, file(pn)    end    def test_shebang_with_options @@ -130,7 +174,7 @@ class TextExecutableTests < Test::Unit::TestCase      assert pn.text_executable?      assert_equal [], pn.archs      assert pn.arch == :dunno -    assert_match /text executable/, `/usr/bin/file -h '#{pn}'`.chomp +    assert_match /text executable/, file(pn)    end    def test_malformed_shebang @@ -146,7 +190,7 @@ class TextExecutableTests < Test::Unit::TestCase      assert !pn.text_executable?      assert_equal [], pn.archs      assert pn.arch == :dunno -    assert_no_match /text executable/, `/usr/bin/file -h '#{pn}'`.chomp +    assert_no_match /text executable/, file(pn)    end    def teardown  | 
