aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-07-16 21:08:10 +0100
committerMike McQuaid2016-07-27 15:05:42 -0600
commit51dd73dba818607fe107b99c1080cab671055e0d (patch)
treebd26d214e56836bb8a92665b951374e27b484288 /Library
parent7f2f602e440d109e10fa75b1d312b8c228371f5c (diff)
downloadbrew-51dd73dba818607fe107b99c1080cab671055e0d.tar.bz2
test_keg: port to generic layer.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_keg.rb31
-rw-r--r--Library/Homebrew/test/test_os_mac_keg.rb69
2 files changed, 69 insertions, 31 deletions
diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb
index f02a65a32..9e4254667 100644
--- a/Library/Homebrew/test/test_keg.rb
+++ b/Library/Homebrew/test/test_keg.rb
@@ -304,35 +304,4 @@ class LinkTests < Homebrew::TestCase
keg.unlink
keg.uninstall
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
- keg.uninstall
- 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
- keg.uninstall
- end
end
diff --git a/Library/Homebrew/test/test_os_mac_keg.rb b/Library/Homebrew/test/test_os_mac_keg.rb
new file mode 100644
index 000000000..e79cbc921
--- /dev/null
+++ b/Library/Homebrew/test/test_os_mac_keg.rb
@@ -0,0 +1,69 @@
+require "testing_env"
+require "keg"
+require "stringio"
+
+class OSMacLinkTests < Homebrew::TestCase
+ include FileUtils
+
+ def setup
+ 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
+ @keg.uninstall
+
+ $stdout = @old_stdout
+
+ rmtree HOMEBREW_PREFIX/"bin"
+ rmtree HOMEBREW_PREFIX/"lib"
+ 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
+ keg.uninstall
+ 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
+ keg.uninstall
+ end
+end