* lib/fileutils.rb (fu_each_src_dest): raise if src==dest. [ruby-talk:85344] [ruby-core:01699]
* lib/fileutils.rb: use Object#is_a? instead of Class#=== to allow e.g. remote objects for receivers. * lib/fileutils.rb: FileTest -> File. * lib/fileutils.rb: put parentheses for arguments of File.xxxx? * test/fileutils/test_fileutils.rb (test_cp): test "cp a a". * test/fileutils/test_fileutils.rb (test_mv): test "mv a a". * test/fileutils/test_fileutils.rb (test_ln): test "ln a a". * test/fileutils/test_fileutils.rb (test_ln_s): test "ln_s a a". * test/fileutils/test_fileutils.rb (test_install): test "install a a". * test/fileutils/fileasserts.rb: new method assert_symlink. * test/fileutils/fileasserts.rb: assert_is_directory -> assert_directory. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c88ad2a387
commit
2bfd5c1a3d
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
Tue Nov 18 14:06:35 2003 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* lib/fileutils.rb (fu_each_src_dest): raise if src==dest.
|
||||||
|
[ruby-talk:85344] [ruby-core:01699]
|
||||||
|
|
||||||
|
* lib/fileutils.rb: use Object#is_a? instead of Class#=== to allow
|
||||||
|
e.g. remote objects for receivers.
|
||||||
|
|
||||||
|
* lib/fileutils.rb: FileTest -> File.
|
||||||
|
|
||||||
|
* lib/fileutils.rb: put parentheses for arguments of File.xxxx?
|
||||||
|
|
||||||
|
* test/fileutils/test_fileutils.rb (test_cp): test "cp a a".
|
||||||
|
|
||||||
|
* test/fileutils/test_fileutils.rb (test_mv): test "mv a a".
|
||||||
|
|
||||||
|
* test/fileutils/test_fileutils.rb (test_ln): test "ln a a".
|
||||||
|
|
||||||
|
* test/fileutils/test_fileutils.rb (test_ln_s): test "ln_s a a".
|
||||||
|
|
||||||
|
* test/fileutils/test_fileutils.rb (test_install): test "install a a".
|
||||||
|
|
||||||
|
* test/fileutils/fileasserts.rb: new method assert_symlink.
|
||||||
|
|
||||||
|
* test/fileutils/fileasserts.rb: assert_is_directory -> assert_directory.
|
||||||
|
|
||||||
Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/optparse.rb (OptionParser::Completion::complete): allow least
|
* lib/optparse.rb (OptionParser::Completion::complete): allow least
|
||||||
|
@ -114,10 +114,10 @@ module FileUtils
|
|||||||
def uptodate?( new, old_list, options = nil )
|
def uptodate?( new, old_list, options = nil )
|
||||||
raise ArgumentError, 'uptodate? does not accept any option' if options
|
raise ArgumentError, 'uptodate? does not accept any option' if options
|
||||||
|
|
||||||
return false unless FileTest.exist?(new)
|
return false unless File.exist?(new)
|
||||||
new_time = File.mtime(new)
|
new_time = File.mtime(new)
|
||||||
old_list.each do |old|
|
old_list.each do |old|
|
||||||
if FileTest.exist?(old)
|
if File.exist?(old)
|
||||||
return false unless new_time > File.mtime(old)
|
return false unless new_time > File.mtime(old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -172,7 +172,7 @@ module FileUtils
|
|||||||
mode = options[:mode] || (0777 & ~File.umask)
|
mode = options[:mode] || (0777 & ~File.umask)
|
||||||
list.map {|n| File.expand_path(n) }.each do |dir|
|
list.map {|n| File.expand_path(n) }.each do |dir|
|
||||||
stack = []
|
stack = []
|
||||||
until FileTest.directory?(dir)
|
until File.directory?(dir)
|
||||||
stack.push dir
|
stack.push dir
|
||||||
dir = File.dirname(dir)
|
dir = File.dirname(dir)
|
||||||
end
|
end
|
||||||
@ -237,7 +237,7 @@ module FileUtils
|
|||||||
fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
||||||
return if options[:noop]
|
return if options[:noop]
|
||||||
|
|
||||||
fu_each_src_dest(src, dest) do |s,d|
|
fu_each_src_dest0(src, dest) do |s,d|
|
||||||
remove_file d, true if options[:force]
|
remove_file d, true if options[:force]
|
||||||
File.link s, d
|
File.link s, d
|
||||||
end
|
end
|
||||||
@ -272,7 +272,7 @@ module FileUtils
|
|||||||
fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
||||||
return if options[:noop]
|
return if options[:noop]
|
||||||
|
|
||||||
fu_each_src_dest(src, dest) do |s,d|
|
fu_each_src_dest0(src, dest) do |s,d|
|
||||||
remove_file d, true if options[:force]
|
remove_file d, true if options[:force]
|
||||||
File.symlink s, d
|
File.symlink s, d
|
||||||
end
|
end
|
||||||
@ -343,7 +343,7 @@ module FileUtils
|
|||||||
return if options[:noop]
|
return if options[:noop]
|
||||||
|
|
||||||
fu_each_src_dest(src, dest) do |s,d|
|
fu_each_src_dest(src, dest) do |s,d|
|
||||||
if FileTest.directory?(s)
|
if File.directory?(s)
|
||||||
fu_copy_dir s, d, '.', options[:preserve]
|
fu_copy_dir s, d, '.', options[:preserve]
|
||||||
else
|
else
|
||||||
fu_p_copy s, d, options[:preserve]
|
fu_p_copy s, d, options[:preserve]
|
||||||
@ -354,10 +354,10 @@ module FileUtils
|
|||||||
def fu_copy_dir( src, dest, rel, preserve ) #:nodoc:
|
def fu_copy_dir( src, dest, rel, preserve ) #:nodoc:
|
||||||
fu_preserve_attr(preserve, "#{src}/#{rel}", "#{dest}/#{rel}") {|s,d|
|
fu_preserve_attr(preserve, "#{src}/#{rel}", "#{dest}/#{rel}") {|s,d|
|
||||||
dir = File.expand_path(d) # to remove '/./'
|
dir = File.expand_path(d) # to remove '/./'
|
||||||
Dir.mkdir dir unless FileTest.directory? dir
|
Dir.mkdir dir unless File.directory?(dir)
|
||||||
}
|
}
|
||||||
Dir.entries("#{src}/#{rel}").each do |fname|
|
Dir.entries("#{src}/#{rel}").each do |fname|
|
||||||
if FileTest.directory? File.join(src,rel,fname)
|
if File.directory?(File.join(src,rel,fname))
|
||||||
next if /\A\.\.?\z/ === fname
|
next if /\A\.\.?\z/ === fname
|
||||||
fu_copy_dir src, dest, "#{rel}/#{fname}", preserve
|
fu_copy_dir src, dest, "#{rel}/#{fname}", preserve
|
||||||
else
|
else
|
||||||
@ -437,14 +437,14 @@ module FileUtils
|
|||||||
return if options[:noop]
|
return if options[:noop]
|
||||||
|
|
||||||
fu_each_src_dest(src, dest) do |s,d|
|
fu_each_src_dest(src, dest) do |s,d|
|
||||||
if cannot_overwrite_file? and FileTest.file?(d)
|
if cannot_overwrite_file? and File.file?(d)
|
||||||
File.unlink d
|
File.unlink d
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
File.rename s, d
|
File.rename s, d
|
||||||
rescue
|
rescue
|
||||||
if FileTest.symlink?(s)
|
if File.symlink?(s)
|
||||||
File.symlink File.readlink(s), dest
|
File.symlink File.readlink(s), dest
|
||||||
File.unlink s
|
File.unlink s
|
||||||
else
|
else
|
||||||
@ -574,7 +574,7 @@ module FileUtils
|
|||||||
Dir.foreach(dir) do |file|
|
Dir.foreach(dir) do |file|
|
||||||
next if /\A\.\.?\z/ === file
|
next if /\A\.\.?\z/ === file
|
||||||
path = "#{dir}/#{file}"
|
path = "#{dir}/#{file}"
|
||||||
if FileTest.directory? path
|
if File.directory?(path)
|
||||||
remove_dir path, force
|
remove_dir path, force
|
||||||
else
|
else
|
||||||
remove_file path, force
|
remove_file path, force
|
||||||
@ -639,7 +639,7 @@ module FileUtils
|
|||||||
return if options[:noop]
|
return if options[:noop]
|
||||||
|
|
||||||
fu_each_src_dest(src, dest) do |s,d|
|
fu_each_src_dest(src, dest) do |s,d|
|
||||||
unless FileTest.exist?(d) and compare_file(s,d)
|
unless File.exist?(d) and compare_file(s,d)
|
||||||
remove_file d, true
|
remove_file d, true
|
||||||
st = File.stat(s) if options[:preserve]
|
st = File.stat(s) if options[:preserve]
|
||||||
copy_file s, d
|
copy_file s, d
|
||||||
@ -707,15 +707,22 @@ module FileUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fu_list( arg )
|
def fu_list( arg )
|
||||||
Array === arg ? arg : [arg]
|
arg.is_a?(Array) ? arg : [arg]
|
||||||
end
|
end
|
||||||
|
|
||||||
def fu_each_src_dest( src, dest )
|
def fu_each_src_dest( src, dest )
|
||||||
unless Array === src
|
fu_each_src_dest0(src, dest) do |s, d|
|
||||||
|
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
|
||||||
|
yield s, d
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def fu_each_src_dest0( src, dest )
|
||||||
|
unless src.is_a?(Array)
|
||||||
yield src, fu_dest_filename(src, dest)
|
yield src, fu_dest_filename(src, dest)
|
||||||
else
|
else
|
||||||
dir = dest
|
dir = dest
|
||||||
# FileTest.directory? dir or raise ArgumentError, "must be dir: #{dir}"
|
#raise ArgumentError, "not a directory: #{dir}" unless File.directory?(dir)
|
||||||
dir += (dir[-1,1] == '/') ? '' : '/'
|
dir += (dir[-1,1] == '/') ? '' : '/'
|
||||||
src.each do |fname|
|
src.each do |fname|
|
||||||
yield fname, dir + File.basename(fname)
|
yield fname, dir + File.basename(fname)
|
||||||
@ -724,13 +731,45 @@ module FileUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fu_dest_filename( src, dest )
|
def fu_dest_filename( src, dest )
|
||||||
if FileTest.directory? dest
|
if File.directory?(dest)
|
||||||
(dest[-1,1] == '/' ? dest : dest + '/') + File.basename(src)
|
(dest[-1,1] == '/' ? dest : dest + '/') + File.basename(src)
|
||||||
else
|
else
|
||||||
dest
|
dest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fu_same?( a, b )
|
||||||
|
fu_resolve_symlink(a) == fu_resolve_symlink(b)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fu_resolve_symlink( path, limit = 128 )
|
||||||
|
raise Errno::ELOOP, "too many levels of symlic links: #{path}" if limit < 0
|
||||||
|
if File.symlink?(path)
|
||||||
|
then fu_resolve_symlink(fu_readlink(File.expand_path(path)), limit-1)
|
||||||
|
else path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def fu_readlink( path )
|
||||||
|
dest = File.readlink(path)
|
||||||
|
if absolute_path?(dest)
|
||||||
|
then dest
|
||||||
|
else File.dirname(File.expand_path(path)) + '/' + dest
|
||||||
|
path = File.readlink(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def absolute_path?( path )
|
||||||
|
if have_drive_letter?
|
||||||
|
then %r<\A([a-z]:)?/> === path
|
||||||
|
else %r<\A/> === path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def have_drive_letter?
|
||||||
|
File::ALT_SEPARATOR ? true : false
|
||||||
|
end
|
||||||
|
|
||||||
def fu_stream_blksize( *streams )
|
def fu_stream_blksize( *streams )
|
||||||
streams.each do |s|
|
streams.each do |s|
|
||||||
next unless s.respond_to?(:stat)
|
next unless s.respond_to?(:stat)
|
||||||
@ -750,7 +789,7 @@ module FileUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fu_update_option( args, new )
|
def fu_update_option( args, new )
|
||||||
if Hash === args.last
|
if args.last.is_a?(Hash)
|
||||||
args.last.update new
|
args.last.update new
|
||||||
else
|
else
|
||||||
args.push new
|
args.push new
|
||||||
@ -836,7 +875,7 @@ module FileUtils
|
|||||||
@fileutils_nowrite = true
|
@fileutils_nowrite = true
|
||||||
|
|
||||||
FileUtils::OPT_TABLE.each do |name, opts|
|
FileUtils::OPT_TABLE.each do |name, opts|
|
||||||
next unless opts.include? 'noop'
|
next unless opts.include?('noop')
|
||||||
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
||||||
def #{name}( *args )
|
def #{name}( *args )
|
||||||
unless defined?(@fileutils_nowrite)
|
unless defined?(@fileutils_nowrite)
|
||||||
|
@ -14,26 +14,34 @@ module Test
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_file_exist( file )
|
def assert_file_exist( path )
|
||||||
_wrap_assertion {
|
_wrap_assertion {
|
||||||
assert_block("file not exist: #{file}") {
|
assert_block("file not exist: #{path}") {
|
||||||
File.exist?(file)
|
File.exist?(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_file_not_exist( file )
|
def assert_file_not_exist( path )
|
||||||
_wrap_assertion {
|
_wrap_assertion {
|
||||||
assert_block("file not exist: #{file}") {
|
assert_block("file not exist: #{path}") {
|
||||||
not File.exist?(file)
|
not File.exist?(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_is_directory( file )
|
def assert_directory( path )
|
||||||
_wrap_assertion {
|
_wrap_assertion {
|
||||||
assert_block("is not directory: #{file}") {
|
assert_block("is not directory: #{path}") {
|
||||||
File.directory?(file)
|
File.directory?(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_symlink( path )
|
||||||
|
_wrap_assertion {
|
||||||
|
assert_block("is no symlink: #{path}") {
|
||||||
|
File.symlink?(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -142,6 +142,22 @@ end
|
|||||||
assert_equal a.uid, b.uid
|
assert_equal a.uid, b.uid
|
||||||
assert_equal a.gid, b.gid
|
assert_equal a.gid, b.gid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# src==dest
|
||||||
|
touch 'tmp/cptmp'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
cp 'tmp/cptmp', 'tmp/cptmp'
|
||||||
|
}
|
||||||
|
if have_symlink?
|
||||||
|
File.symlink 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
cp 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
}
|
||||||
|
File.symlink 'tmp/symlink', 'tmp/symlink'
|
||||||
|
assert_raises(Errno::ELOOP) {
|
||||||
|
cp 'tmp/symlink', 'tmp/symlink'
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cp_r
|
def test_cp_r
|
||||||
@ -157,6 +173,22 @@ end
|
|||||||
mv 'tmp/mvsrc', 'tmp/mvdest'
|
mv 'tmp/mvsrc', 'tmp/mvdest'
|
||||||
assert_same_file fname, 'tmp/mvdest'
|
assert_same_file fname, 'tmp/mvdest'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# src==dest
|
||||||
|
touch 'tmp/cptmp'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
mv 'tmp/cptmp', 'tmp/cptmp'
|
||||||
|
}
|
||||||
|
if have_symlink?
|
||||||
|
File.symlink 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
mv 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
}
|
||||||
|
File.symlink 'tmp/symlink', 'tmp/symlink'
|
||||||
|
assert_raises(Errno::ELOOP) {
|
||||||
|
mv 'tmp/symlink', 'tmp/symlink'
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rm
|
def test_rm
|
||||||
@ -249,6 +281,22 @@ end
|
|||||||
TARGETS.each do |fname|
|
TARGETS.each do |fname|
|
||||||
File.unlink 'tmp/' + File.basename(fname)
|
File.unlink 'tmp/' + File.basename(fname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# src==dest
|
||||||
|
touch 'tmp/cptmp'
|
||||||
|
assert_raises(Errno::EEXIST) {
|
||||||
|
ln 'tmp/cptmp', 'tmp/cptmp'
|
||||||
|
}
|
||||||
|
if have_symlink?
|
||||||
|
File.symlink 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
assert_raises(Errno::EEXIST) {
|
||||||
|
ln 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
}
|
||||||
|
File.symlink 'tmp/symlink', 'tmp/symlink'
|
||||||
|
assert_raises(Errno::EEXIST) {
|
||||||
|
ln 'tmp/symlink', 'tmp/symlink'
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if have_symlink?
|
if have_symlink?
|
||||||
@ -259,6 +307,10 @@ if have_symlink?
|
|||||||
assert_equal fname, File.readlink('tmp/lnsdest')
|
assert_equal fname, File.readlink('tmp/lnsdest')
|
||||||
rm_f 'tmp/lnsdest'
|
rm_f 'tmp/lnsdest'
|
||||||
end
|
end
|
||||||
|
assert_nothing_raised {
|
||||||
|
ln_s 'tmp/symlink', 'tmp/symlink'
|
||||||
|
}
|
||||||
|
assert_symlink 'tmp/symlink'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -277,15 +329,15 @@ end
|
|||||||
def test_mkdir
|
def test_mkdir
|
||||||
my_rm_rf 'tmpdatadir'
|
my_rm_rf 'tmpdatadir'
|
||||||
mkdir 'tmpdatadir'
|
mkdir 'tmpdatadir'
|
||||||
assert_is_directory 'tmpdatadir'
|
assert_directory 'tmpdatadir'
|
||||||
Dir.rmdir 'tmpdatadir'
|
Dir.rmdir 'tmpdatadir'
|
||||||
|
|
||||||
mkdir 'tmp/mkdirdest'
|
mkdir 'tmp/mkdirdest'
|
||||||
assert_is_directory 'tmp/mkdirdest'
|
assert_directory 'tmp/mkdirdest'
|
||||||
Dir.rmdir 'tmp/mkdirdest'
|
Dir.rmdir 'tmp/mkdirdest'
|
||||||
|
|
||||||
mkdir 'tmp/tmp', :mode => 0700
|
mkdir 'tmp/tmp', :mode => 0700
|
||||||
assert_is_directory 'tmp/tmp'
|
assert_directory 'tmp/tmp'
|
||||||
assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows?
|
assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows?
|
||||||
Dir.rmdir 'tmp/tmp'
|
Dir.rmdir 'tmp/tmp'
|
||||||
end
|
end
|
||||||
@ -307,7 +359,7 @@ end
|
|||||||
rm_rf 'tmpdir'
|
rm_rf 'tmpdir'
|
||||||
dirs.each do |d|
|
dirs.each do |d|
|
||||||
mkdir_p d
|
mkdir_p d
|
||||||
assert_is_directory d
|
assert_directory d
|
||||||
assert_file_not_exist "#{d}/a"
|
assert_file_not_exist "#{d}/a"
|
||||||
assert_file_not_exist "#{d}/b"
|
assert_file_not_exist "#{d}/b"
|
||||||
assert_file_not_exist "#{d}/c"
|
assert_file_not_exist "#{d}/c"
|
||||||
@ -315,13 +367,13 @@ end
|
|||||||
end
|
end
|
||||||
dirs.each do |d|
|
dirs.each do |d|
|
||||||
mkdir_p d
|
mkdir_p d
|
||||||
assert_is_directory d
|
assert_directory d
|
||||||
end
|
end
|
||||||
rm_rf 'tmpdir'
|
rm_rf 'tmpdir'
|
||||||
|
|
||||||
mkdir_p 'tmp/tmp/tmp', :mode => 0700
|
mkdir_p 'tmp/tmp/tmp', :mode => 0700
|
||||||
assert_is_directory 'tmp/tmp'
|
assert_directory 'tmp/tmp'
|
||||||
assert_is_directory 'tmp/tmp/tmp'
|
assert_directory 'tmp/tmp/tmp'
|
||||||
assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows?
|
assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows?
|
||||||
assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) unless windows?
|
assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) unless windows?
|
||||||
rm_rf 'tmp/tmp'
|
rm_rf 'tmp/tmp'
|
||||||
@ -353,6 +405,22 @@ end
|
|||||||
|
|
||||||
File.unlink 'tmp/aaa'
|
File.unlink 'tmp/aaa'
|
||||||
File.unlink 'tmp/bbb'
|
File.unlink 'tmp/bbb'
|
||||||
|
|
||||||
|
# src==dest
|
||||||
|
touch 'tmp/cptmp'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
install 'tmp/cptmp', 'tmp/cptmp'
|
||||||
|
}
|
||||||
|
if have_symlink?
|
||||||
|
File.symlink 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
install 'tmp/cptmp', 'tmp/cptmp_symlink'
|
||||||
|
}
|
||||||
|
File.symlink 'tmp/symlink', 'tmp/symlink'
|
||||||
|
assert_raises(Errno::ELOOP) {
|
||||||
|
install 'tmp/symlink', 'tmp/symlink'
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user