tests: fix leak in '[un]linkapps' integration test (#439)
Prior to the fix, every run of the test suite would leave behind a pair of empty directories in `$TMPDIR`. (A temporary home directory was created but only its child `Applications` was wiped when done.)
This commit is contained in:
parent
59074e91d6
commit
1b1bf56733
@ -424,24 +424,23 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_linkapps
|
def test_linkapps
|
||||||
home = mktmpdir
|
home_dir = Pathname.new(mktmpdir)
|
||||||
apps_dir = Pathname.new(home).join("Applications")
|
(home_dir/"Applications").mkpath
|
||||||
apps_dir.mkpath
|
|
||||||
|
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app"
|
source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app"
|
||||||
source_dir.mkpath
|
source_dir.mkpath
|
||||||
assert_match "Linking: #{source_dir}",
|
assert_match "Linking: #{source_dir}",
|
||||||
cmd("linkapps", "--local", "HOME" => home)
|
cmd("linkapps", "--local", "HOME" => home_dir)
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_rf apps_dir
|
home_dir.rmtree
|
||||||
(HOMEBREW_CELLAR/"testball").rmtree
|
(HOMEBREW_CELLAR/"testball").rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unlinkapps
|
def test_unlinkapps
|
||||||
home = mktmpdir
|
home_dir = Pathname.new(mktmpdir)
|
||||||
apps_dir = Pathname.new(home).join("Applications")
|
apps_dir = home_dir/"Applications"
|
||||||
apps_dir.mkpath
|
apps_dir.mkpath
|
||||||
|
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
@ -452,9 +451,9 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app"
|
FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app"
|
||||||
|
|
||||||
assert_match "Unlinking: #{apps_dir}/TestBall.app",
|
assert_match "Unlinking: #{apps_dir}/TestBall.app",
|
||||||
cmd("unlinkapps", "--local", "HOME" => home)
|
cmd("unlinkapps", "--local", "HOME" => home_dir)
|
||||||
ensure
|
ensure
|
||||||
apps_dir.rmtree
|
home_dir.rmtree
|
||||||
(HOMEBREW_CELLAR/"testball").rmtree
|
(HOMEBREW_CELLAR/"testball").rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user