blob: d1103415dece628c685ee42d6471407bbea01fe1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  | 
require "testing_env"
require "keg"
require "stringio"
class OSMacLinkTests < Homebrew::TestCase
  include FileUtils
  def setup
    super
    keg = HOMEBREW_CELLAR.join("foo", "1.0")
    keg.join("bin").mkpath
    %w[hiworld helloworld goodbye_cruel_world].each do |file|
      touch keg.join("bin", file)
    end
    @keg = Keg.new(keg)
    @dst = HOMEBREW_PREFIX.join("bin", "helloworld")
    @nonexistent = Pathname.new("/some/nonexistent/path")
    @mode = OpenStruct.new
    @old_stdout = $stdout
    $stdout = StringIO.new
    mkpath HOMEBREW_PREFIX/"bin"
    mkpath HOMEBREW_PREFIX/"lib"
  end
  def teardown
    @keg.unlink
    $stdout = @old_stdout
    rmtree HOMEBREW_PREFIX/"lib"
    super
  end
  def test_mach_o_files_skips_hardlinks
    a = HOMEBREW_CELLAR/"a/1.0"
    (a/"lib").mkpath
    FileUtils.cp dylib_path("i386"), a/"lib/i386.dylib"
    FileUtils.ln a/"lib/i386.dylib", a/"lib/i386_link.dylib"
    keg = Keg.new(a)
    keg.link
    assert_equal 1, keg.mach_o_files.size
  ensure
    keg.unlink
  end
  def test_mach_o_files_isnt_confused_by_symlinks
    a = HOMEBREW_CELLAR/"a/1.0"
    (a/"lib").mkpath
    FileUtils.cp dylib_path("i386"), a/"lib/i386.dylib"
    FileUtils.ln a/"lib/i386.dylib", a/"lib/i386_link.dylib"
    FileUtils.ln_s a/"lib/i386.dylib", a/"lib/1.dylib"
    keg = Keg.new(a)
    keg.link
    assert_equal 1, keg.mach_o_files.size
  ensure
    keg.unlink
  end
end
  |