test_fileutils.rb: no broken symlinks on Cygwin
* test/fileutils/test_fileutils.rb (no_broken_symlink): exclude test using broken symlinks on Cygwin, which are not allowed because of the directory flag of Windows native symlink. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1b4df62546
commit
3d031cea42
@ -74,6 +74,15 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@no_broken_symlink = false
|
||||||
|
if /cygwin/ =~ RUBY_PLATFORM and /\bwinsymlinks:native(?:strict)?\b/ =~ ENV["CYGWIN"]
|
||||||
|
@@no_broken_symlink = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def no_broken_symlink?
|
||||||
|
@@no_broken_symlink
|
||||||
|
end
|
||||||
|
|
||||||
def root_in_posix?
|
def root_in_posix?
|
||||||
if /cygwin/ =~ RUBY_PLATFORM
|
if /cygwin/ =~ RUBY_PLATFORM
|
||||||
# FIXME: privilege if groups include root user?
|
# FIXME: privilege if groups include root user?
|
||||||
@ -324,6 +333,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError) {
|
assert_raise(ArgumentError) {
|
||||||
cp 'tmp/cptmp_symlink', 'tmp/cptmp'
|
cp 'tmp/cptmp_symlink', 'tmp/cptmp'
|
||||||
}
|
}
|
||||||
|
return if no_broken_symlink?
|
||||||
# src==dest (3) looped symlink
|
# src==dest (3) looped symlink
|
||||||
File.symlink 'symlink', 'tmp/symlink'
|
File.symlink 'symlink', 'tmp/symlink'
|
||||||
assert_raise(Errno::ELOOP) {
|
assert_raise(Errno::ELOOP) {
|
||||||
@ -390,6 +400,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
def test_cp_r_symlink
|
def test_cp_r_symlink
|
||||||
# symlink in a directory
|
# symlink in a directory
|
||||||
mkdir 'tmp/cpr_src'
|
mkdir 'tmp/cpr_src'
|
||||||
|
touch 'tmp/cpr_src/SLdest'
|
||||||
ln_s 'SLdest', 'tmp/cpr_src/symlink'
|
ln_s 'SLdest', 'tmp/cpr_src/symlink'
|
||||||
cp_r 'tmp/cpr_src', 'tmp/cpr_dest'
|
cp_r 'tmp/cpr_src', 'tmp/cpr_dest'
|
||||||
assert_symlink 'tmp/cpr_dest/symlink'
|
assert_symlink 'tmp/cpr_dest/symlink'
|
||||||
@ -415,7 +426,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
cp_r 'tmp/cross', 'tmp/cross2', :preserve => true
|
cp_r 'tmp/cross', 'tmp/cross2', :preserve => true
|
||||||
}
|
}
|
||||||
end if have_symlink?
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
def test_cp_r_pathname
|
def test_cp_r_pathname
|
||||||
# pathname
|
# pathname
|
||||||
@ -471,6 +482,9 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError) {
|
assert_raise(ArgumentError) {
|
||||||
mv 'tmp/cptmp_symlink', 'tmp/cptmp'
|
mv 'tmp/cptmp_symlink', 'tmp/cptmp'
|
||||||
}
|
}
|
||||||
|
end if have_symlink?
|
||||||
|
|
||||||
|
def test_mv_broken_symlink
|
||||||
# src==dest (3) looped symlink
|
# src==dest (3) looped symlink
|
||||||
File.symlink 'symlink', 'tmp/symlink'
|
File.symlink 'symlink', 'tmp/symlink'
|
||||||
assert_raise(Errno::ELOOP) {
|
assert_raise(Errno::ELOOP) {
|
||||||
@ -482,7 +496,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
mv 'tmp/src', 'tmp/dest'
|
mv 'tmp/src', 'tmp/dest'
|
||||||
}
|
}
|
||||||
assert_equal true, File.symlink?('tmp/dest')
|
assert_equal true, File.symlink?('tmp/dest')
|
||||||
end if have_symlink?
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
def test_mv_pathname
|
def test_mv_pathname
|
||||||
# pathname
|
# pathname
|
||||||
@ -744,6 +758,9 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_raise(Errno::EEXIST) {
|
assert_raise(Errno::EEXIST) {
|
||||||
ln 'tmp/symlink', 'tmp/cptmp' # symlink -> normal file
|
ln 'tmp/symlink', 'tmp/cptmp' # symlink -> normal file
|
||||||
}
|
}
|
||||||
|
end if have_symlink?
|
||||||
|
|
||||||
|
def test_ln_broken_symlink
|
||||||
# src==dest (3) looped symlink
|
# src==dest (3) looped symlink
|
||||||
File.symlink 'cptmp_symlink', 'tmp/cptmp_symlink'
|
File.symlink 'cptmp_symlink', 'tmp/cptmp_symlink'
|
||||||
begin
|
begin
|
||||||
@ -751,7 +768,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
rescue => err
|
rescue => err
|
||||||
assert_kind_of SystemCallError, err
|
assert_kind_of SystemCallError, err
|
||||||
end
|
end
|
||||||
end if have_symlink?
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
def test_ln_pathname
|
def test_ln_pathname
|
||||||
# pathname
|
# pathname
|
||||||
@ -773,11 +790,16 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_equal fname, File.readlink('tmp/lnsdest')
|
assert_equal fname, File.readlink('tmp/lnsdest')
|
||||||
rm_f 'tmp/lnsdest'
|
rm_f 'tmp/lnsdest'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ln_s_broken_symlink
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
ln_s 'symlink', 'tmp/symlink'
|
ln_s 'symlink', 'tmp/symlink'
|
||||||
}
|
}
|
||||||
assert_symlink 'tmp/symlink'
|
assert_symlink 'tmp/symlink'
|
||||||
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
|
def test_ln_s_pathname
|
||||||
# pathname
|
# pathname
|
||||||
touch 'tmp/lnsdest'
|
touch 'tmp/lnsdest'
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
@ -798,10 +820,15 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
ln_sf fname, 'tmp/lnsdest'
|
ln_sf fname, 'tmp/lnsdest'
|
||||||
ln_sf fname, 'tmp/lnsdest'
|
ln_sf fname, 'tmp/lnsdest'
|
||||||
end
|
end
|
||||||
|
end if have_symlink?
|
||||||
|
|
||||||
|
def test_ln_sf_broken_symlink
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
ln_sf 'symlink', 'tmp/symlink'
|
ln_sf 'symlink', 'tmp/symlink'
|
||||||
}
|
}
|
||||||
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
|
def test_ln_sf_pathname
|
||||||
# pathname
|
# pathname
|
||||||
touch 'tmp/lns_dest'
|
touch 'tmp/lns_dest'
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
@ -981,13 +1008,16 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError) {
|
assert_raise(ArgumentError) {
|
||||||
install 'tmp/cptmp_symlink', 'tmp/cptmp'
|
install 'tmp/cptmp_symlink', 'tmp/cptmp'
|
||||||
}
|
}
|
||||||
|
end if have_symlink?
|
||||||
|
|
||||||
|
def test_install_broken_symlink
|
||||||
# src==dest (3) looped symlink
|
# src==dest (3) looped symlink
|
||||||
File.symlink 'symlink', 'tmp/symlink'
|
File.symlink 'symlink', 'tmp/symlink'
|
||||||
assert_raise(Errno::ELOOP) {
|
assert_raise(Errno::ELOOP) {
|
||||||
# File#install invokes open(2), always ELOOP must be raised
|
# File#install invokes open(2), always ELOOP must be raised
|
||||||
install 'tmp/symlink', 'tmp/symlink'
|
install 'tmp/symlink', 'tmp/symlink'
|
||||||
}
|
}
|
||||||
end if have_symlink?
|
end if have_symlink? and !no_broken_symlink?
|
||||||
|
|
||||||
def test_install_pathname
|
def test_install_pathname
|
||||||
# pathname
|
# pathname
|
||||||
@ -1389,6 +1419,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_copy_entry_symlink
|
def test_copy_entry_symlink
|
||||||
# root is a symlink
|
# root is a symlink
|
||||||
|
touch 'tmp/somewhere'
|
||||||
File.symlink 'somewhere', 'tmp/symsrc'
|
File.symlink 'somewhere', 'tmp/symsrc'
|
||||||
copy_entry 'tmp/symsrc', 'tmp/symdest'
|
copy_entry 'tmp/symsrc', 'tmp/symdest'
|
||||||
assert_symlink 'tmp/symdest'
|
assert_symlink 'tmp/symdest'
|
||||||
@ -1396,6 +1427,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
|
|
||||||
# content is a symlink
|
# content is a symlink
|
||||||
mkdir 'tmp/dir'
|
mkdir 'tmp/dir'
|
||||||
|
touch 'tmp/dir/somewhere'
|
||||||
File.symlink 'somewhere', 'tmp/dir/sym'
|
File.symlink 'somewhere', 'tmp/dir/sym'
|
||||||
copy_entry 'tmp/dir', 'tmp/dirdest'
|
copy_entry 'tmp/dir', 'tmp/dirdest'
|
||||||
assert_directory 'tmp/dirdest'
|
assert_directory 'tmp/dirdest'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user