diff options
| author | Markus Reiter | 2017-02-21 20:10:49 +0100 |
|---|---|---|
| committer | GitHub | 2017-02-21 20:10:49 +0100 |
| commit | 6d4aa91b3768cefc35c5adf55ced4928795a89f8 (patch) | |
| tree | f05106aa6bd330fa42ee68c365d44c970eca5bfe /Library/Homebrew/test/os | |
| parent | a5af18380ba4c159796b335c5ac453e3529b57a2 (diff) | |
| parent | 5ec95978104eab9679340e739c3a5fd5786b4722 (diff) | |
| download | brew-6d4aa91b3768cefc35c5adf55ced4928795a89f8.tar.bz2 | |
Merge pull request #2076 from reitermarkus/spec-os_mac_keg
Convert OS::Mac::Keg test to spec.
Diffstat (limited to 'Library/Homebrew/test/os')
| -rw-r--r-- | Library/Homebrew/test/os/mac/keg_spec.rb | 32 | ||||
| -rw-r--r-- | Library/Homebrew/test/os/mac/keg_test.rb | 69 |
2 files changed, 32 insertions, 69 deletions
diff --git a/Library/Homebrew/test/os/mac/keg_spec.rb b/Library/Homebrew/test/os/mac/keg_spec.rb new file mode 100644 index 000000000..562c2ba6a --- /dev/null +++ b/Library/Homebrew/test/os/mac/keg_spec.rb @@ -0,0 +1,32 @@ +require "keg" + +describe Keg do + include FileUtils + + subject { described_class.new(keg_path) } + + describe "#mach_o_files" do + let(:keg_path) { HOMEBREW_CELLAR/"a/1.0" } + + before(:each) { (keg_path/"lib").mkpath } + + after(:each) { subject.unlink } + + it "skips hardlinks" do + cp dylib_path("i386"), keg_path/"lib/i386.dylib" + ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib" + + subject.link + expect(subject.mach_o_files.count).to eq(1) + end + + it "isn't confused by symlinks" do + cp dylib_path("i386"), keg_path/"lib/i386.dylib" + ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib" + ln_s keg_path/"lib/i386.dylib", keg_path/"lib/i386_symlink.dylib" + + subject.link + expect(subject.mach_o_files.count).to eq(1) + end + end +end diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb deleted file mode 100644 index d1103415d..000000000 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -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 |
