tests: add leaves & prune integration tests

Closes Homebrew/homebrew#48943.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2016-02-07 12:47:40 +01:00
parent 570345d1a0
commit eba429d947

View File

@ -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}"