From 62d7079684cdb568600e22531c62888622a71ff1 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Mon, 27 Jun 2016 19:02:40 -0400 Subject: [PATCH] test: Add test for Keg#mach_o_files hardlink behavior. Move dylib_path and bundle_path from test_mach to testing_env to accommodate the new test. Closes #400. Signed-off-by: Tim D. Smith --- Library/Homebrew/test/test_keg.rb | 15 +++++++++++++++ Library/Homebrew/test/test_mach.rb | 8 -------- Library/Homebrew/test/testing_env.rb | 8 ++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb index 9e4254667d1d0..513707d453cb4 100644 --- a/Library/Homebrew/test/test_keg.rb +++ b/Library/Homebrew/test/test_keg.rb @@ -304,4 +304,19 @@ def test_removes_broken_symlinks_that_conflict_with_directories keg.unlink keg.uninstall end + + def test_mach_o_files_skips_hardlinks + a = HOMEBREW_CELLAR.join("a", "1.0") + a.join("lib").mkpath + FileUtils.cp dylib_path("i386"), a.join("lib", "i386.dylib") + FileUtils.ln a.join("lib", "i386.dylib"), a.join("lib", "i386_link.dylib") + + keg = Keg.new(a) + keg.link + + assert_equal 1, keg.mach_o_files.size + ensure + keg.unlink + keg.uninstall + end end diff --git a/Library/Homebrew/test/test_mach.rb b/Library/Homebrew/test/test_mach.rb index a1f62dcf37c5d..404a21d6039cc 100644 --- a/Library/Homebrew/test/test_mach.rb +++ b/Library/Homebrew/test/test_mach.rb @@ -1,14 +1,6 @@ require "testing_env" class MachOPathnameTests < Homebrew::TestCase - def dylib_path(name) - Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.dylib") - end - - def bundle_path(name) - Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.bundle") - end - def test_fat_dylib pn = dylib_path("fat") assert_predicate pn, :universal? diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 4e7089e429ea8..6be622cc5376a 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -112,5 +112,13 @@ def refute_eql(exp, act, msg = nil) } refute exp.eql?(act), msg end + + def dylib_path(name) + Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.dylib") + end + + def bundle_path(name) + Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.bundle") + end end end