test_fileutils.rb: enclose helper methods
* test/fileutils/test_fileutils.rb: enclose helper methods in a module from global functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
20c38381a8
commit
9ef195f8d6
@ -25,71 +25,70 @@ class TestFileUtils < Test::Unit::TestCase
|
|||||||
ensure
|
ensure
|
||||||
fu.instance_variable_set(:@fileutils_output, old) if old
|
fu.instance_variable_set(:@fileutils_output, old) if old
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
prevdir = Dir.pwd
|
m = Module.new do
|
||||||
tmproot = TestFileUtils::TMPROOT
|
def have_drive_letter?
|
||||||
Dir.mkdir tmproot unless File.directory?(tmproot)
|
/mswin(?!ce)|mingw|bcc|emx/ =~ RUBY_PLATFORM
|
||||||
Dir.chdir tmproot
|
end
|
||||||
|
|
||||||
def have_drive_letter?
|
def have_file_perm?
|
||||||
/mswin(?!ce)|mingw|bcc|emx/ =~ RUBY_PLATFORM
|
/mswin|mingw|bcc|emx/ !~ RUBY_PLATFORM
|
||||||
end
|
end
|
||||||
|
|
||||||
def have_file_perm?
|
@@have_symlink = nil
|
||||||
/mswin|mingw|bcc|emx/ !~ RUBY_PLATFORM
|
|
||||||
end
|
|
||||||
|
|
||||||
$fileutils_rb_have_symlink = nil
|
def have_symlink?
|
||||||
|
if @@have_symlink == nil
|
||||||
|
@@have_symlink = check_have_symlink?
|
||||||
|
end
|
||||||
|
@@have_symlink
|
||||||
|
end
|
||||||
|
|
||||||
def have_symlink?
|
def check_have_symlink?
|
||||||
if $fileutils_rb_have_symlink == nil
|
File.symlink nil, nil
|
||||||
$fileutils_rb_have_symlink = check_have_symlink?
|
rescue NotImplementedError
|
||||||
|
return false
|
||||||
|
rescue
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
@@have_hardlink = nil
|
||||||
|
|
||||||
|
def have_hardlink?
|
||||||
|
if @@have_hardlink == nil
|
||||||
|
@@have_hardlink = check_have_hardlink?
|
||||||
|
end
|
||||||
|
@@have_hardlink
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_have_hardlink?
|
||||||
|
File.link nil, nil
|
||||||
|
rescue NotImplementedError
|
||||||
|
return false
|
||||||
|
rescue
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
tmproot = TMPROOT
|
||||||
|
Dir.mkdir tmproot unless File.directory?(tmproot)
|
||||||
|
Dir.chdir tmproot do
|
||||||
|
Dir.mkdir("\n")
|
||||||
|
Dir.rmdir("\n")
|
||||||
|
end
|
||||||
|
def lf_in_path_allowed?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
def lf_in_path_allowed?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
Dir.rmdir tmproot
|
||||||
|
end
|
||||||
end
|
end
|
||||||
$fileutils_rb_have_symlink
|
include m
|
||||||
end
|
extend m
|
||||||
|
|
||||||
def check_have_symlink?
|
|
||||||
File.symlink nil, nil
|
|
||||||
rescue NotImplementedError
|
|
||||||
return false
|
|
||||||
rescue
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
$fileutils_rb_have_hardlink = nil
|
|
||||||
|
|
||||||
def have_hardlink?
|
|
||||||
if $fileutils_rb_have_hardlink == nil
|
|
||||||
$fileutils_rb_have_hardlink = check_have_hardlink?
|
|
||||||
end
|
|
||||||
$fileutils_rb_have_hardlink
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_have_hardlink?
|
|
||||||
File.link nil, nil
|
|
||||||
rescue NotImplementedError
|
|
||||||
return false
|
|
||||||
rescue
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
Dir.mkdir("\n")
|
|
||||||
Dir.rmdir("\n")
|
|
||||||
def lf_in_path_allowed?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
def lf_in_path_allowed?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Dir.chdir prevdir
|
|
||||||
Dir.rmdir tmproot
|
|
||||||
|
|
||||||
class TestFileUtils
|
|
||||||
|
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user