aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorBaptiste Fontaine2016-02-07 12:47:40 +0100
committerBaptiste Fontaine2016-02-07 13:30:40 +0100
commiteba429d947a59ab4d80ccac0cffbe34b3c75c48d (patch)
tree28c36cfb1672872d359e922d48a0c6b6fc980c67 /Library/Homebrew/test
parent570345d1a03b2ab9342ca35f5d71ef6635eaff73 (diff)
downloadbrew-eba429d947a59ab4d80ccac0cffbe34b3c75c48d.tar.bz2
tests: add leaves & prune integration tests
Closes Homebrew/homebrew#48943. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_integration_cmds.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb
index 8b1c7ed34..bca031f5f 100644
--- a/Library/Homebrew/test/test_integration_cmds.rb
+++ b/Library/Homebrew/test/test_integration_cmds.rb
@@ -639,6 +639,56 @@ class IntegrationCommandTests < Homebrew::TestCase
(HOMEBREW_REPOSITORY/".git").rmtree
end
+ def test_leaves
+ formula_dir = CoreFormulaRepository.new.formula_dir
+ formula_file1 = formula_dir/"testball1.rb"
+ formula_file2 = formula_dir/"testball2.rb"
+ formula_file1.write <<-EOS.undent
+ class Testball1 < Formula
+ url "https://example.com/testball1-0.1.tar.gz"
+ end
+ EOS
+ formula_file2.write <<-EOS.undent
+ class Testball2 < Formula
+ url "https://example.com/testball2-0.1.tar.gz"
+ depends_on "testball1"
+ end
+ EOS
+ assert_equal "", cmd("leaves")
+
+ (HOMEBREW_CELLAR/"testball1/0.1/somedir").mkpath
+ assert_equal "testball1", cmd("leaves")
+
+ (HOMEBREW_CELLAR/"testball2/0.1/somedir").mkpath
+ assert_equal "testball2", cmd("leaves")
+ ensure
+ (HOMEBREW_CELLAR/"testball1").rmtree
+ (HOMEBREW_CELLAR/"testball2").rmtree
+ formula_file1.unlink
+ formula_file2.unlink
+ end
+
+ def test_prune
+ share = (HOMEBREW_PREFIX/"share")
+
+ (share/"pruneable/directory/here").mkpath
+ (share/"notpruneable/file").write "I'm here"
+ FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"
+
+ assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here},
+ cmd("prune", "--dry-run")
+ assert_match "Pruned 1 symbolic links and 3 directories",
+ cmd("prune")
+ refute (share/"pruneable").directory?
+ assert (share/"notpruneable").directory?
+ refute (share/"pruneable_symlink").symlink?
+
+ assert_equal "Nothing pruned",
+ cmd("prune", "--verbose")
+ ensure
+ share.rmtree
+ end
+
def test_custom_command
mktmpdir do |path|
cmd = "int-test-#{rand}"