Do less work inside chdir blocks
This commit is contained in:
parent
617544694c
commit
53b7d45de8
@ -96,100 +96,95 @@ class PathnameExtensionTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup_install_test
|
def setup_install_test
|
||||||
cd @src do
|
(@src+'a.txt').write 'This is sample file a.'
|
||||||
(@src+'a.txt').write 'This is sample file a.'
|
(@src+'b.txt').write 'This is sample file b.'
|
||||||
(@src+'b.txt').write 'This is sample file b.'
|
cd(@src) { yield }
|
||||||
yield
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install
|
def test_install
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
@dst.install 'a.txt'
|
@dst.install 'a.txt'
|
||||||
|
|
||||||
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
|
||||||
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
||||||
|
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_list
|
def test_install_list
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
@dst.install %w[a.txt b.txt]
|
@dst.install %w[a.txt b.txt]
|
||||||
|
|
||||||
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
|
||||||
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
||||||
|
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_glob
|
def test_install_glob
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
@dst.install Dir['*.txt']
|
@dst.install Dir['*.txt']
|
||||||
|
|
||||||
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
|
||||||
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
|
||||||
|
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_directory
|
def test_install_directory
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
mkdir_p 'bin'
|
mkdir_p 'bin'
|
||||||
mv Dir['*.txt'], 'bin'
|
mv Dir['*.txt'], 'bin'
|
||||||
|
|
||||||
@dst.install 'bin'
|
@dst.install 'bin'
|
||||||
|
|
||||||
assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
|
|
||||||
assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
|
||||||
|
assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_rename
|
def test_install_rename
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
@dst.install 'a.txt' => 'c.txt'
|
@dst.install 'a.txt' => 'c.txt'
|
||||||
|
|
||||||
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
|
|
||||||
refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
|
|
||||||
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
|
||||||
|
refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
|
||||||
|
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_rename_more
|
def test_install_rename_more
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
@dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
|
@dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
|
||||||
|
|
||||||
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
|
|
||||||
assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
|
|
||||||
refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
|
|
||||||
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
|
||||||
|
assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
|
||||||
|
refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
|
||||||
|
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_rename_directory
|
def test_install_rename_directory
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
mkdir_p 'bin'
|
mkdir_p 'bin'
|
||||||
mv Dir['*.txt'], 'bin'
|
mv Dir['*.txt'], 'bin'
|
||||||
|
|
||||||
@dst.install 'bin' => 'libexec'
|
@dst.install 'bin' => 'libexec'
|
||||||
|
|
||||||
refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
|
|
||||||
assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
|
|
||||||
assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
|
||||||
|
assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
|
||||||
|
assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_symlink
|
def test_install_symlink
|
||||||
setup_install_test do
|
setup_install_test do
|
||||||
mkdir_p 'bin'
|
mkdir_p 'bin'
|
||||||
mv Dir['*.txt'], 'bin'
|
mv Dir['*.txt'], 'bin'
|
||||||
|
|
||||||
@dst.install_symlink @src+'bin'
|
|
||||||
|
|
||||||
assert_predicate @dst+"bin", :symlink?
|
|
||||||
assert_predicate @dst+"bin", :directory?
|
|
||||||
assert_predicate @dst+"bin/a.txt", :exist?
|
|
||||||
assert_predicate @dst+"bin/b.txt", :exist?
|
|
||||||
|
|
||||||
assert_predicate (@dst+"bin").readlink, :relative?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@dst.install_symlink @src+'bin'
|
||||||
|
|
||||||
|
assert_predicate @dst+"bin", :symlink?
|
||||||
|
assert_predicate @dst+"bin", :directory?
|
||||||
|
assert_predicate @dst+"bin/a.txt", :exist?
|
||||||
|
assert_predicate @dst+"bin/b.txt", :exist?
|
||||||
|
assert_predicate (@dst+"bin").readlink, :relative?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_creates_intermediate_directories
|
def test_install_creates_intermediate_directories
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user