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:
nobu 2013-12-24 14:04:35 +00:00
parent 20c38381a8
commit 9ef195f8d6

View File

@ -25,13 +25,8 @@ 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
tmproot = TestFileUtils::TMPROOT
Dir.mkdir tmproot unless File.directory?(tmproot)
Dir.chdir tmproot
m = Module.new do
def have_drive_letter? def have_drive_letter?
/mswin(?!ce)|mingw|bcc|emx/ =~ RUBY_PLATFORM /mswin(?!ce)|mingw|bcc|emx/ =~ RUBY_PLATFORM
end end
@ -40,13 +35,13 @@ def have_file_perm?
/mswin|mingw|bcc|emx/ !~ RUBY_PLATFORM /mswin|mingw|bcc|emx/ !~ RUBY_PLATFORM
end end
$fileutils_rb_have_symlink = nil @@have_symlink = nil
def have_symlink? def have_symlink?
if $fileutils_rb_have_symlink == nil if @@have_symlink == nil
$fileutils_rb_have_symlink = check_have_symlink? @@have_symlink = check_have_symlink?
end end
$fileutils_rb_have_symlink @@have_symlink
end end
def check_have_symlink? def check_have_symlink?
@ -57,13 +52,13 @@ rescue
return true return true
end end
$fileutils_rb_have_hardlink = nil @@have_hardlink = nil
def have_hardlink? def have_hardlink?
if $fileutils_rb_have_hardlink == nil if @@have_hardlink == nil
$fileutils_rb_have_hardlink = check_have_hardlink? @@have_hardlink = check_have_hardlink?
end end
$fileutils_rb_have_hardlink @@have_hardlink
end end
def check_have_hardlink? def check_have_hardlink?
@ -75,8 +70,12 @@ rescue
end end
begin begin
tmproot = TMPROOT
Dir.mkdir tmproot unless File.directory?(tmproot)
Dir.chdir tmproot do
Dir.mkdir("\n") Dir.mkdir("\n")
Dir.rmdir("\n") Dir.rmdir("\n")
end
def lf_in_path_allowed? def lf_in_path_allowed?
true true
end end
@ -84,12 +83,12 @@ rescue
def lf_in_path_allowed? def lf_in_path_allowed?
false false
end end
end ensure
Dir.chdir prevdir
Dir.rmdir tmproot Dir.rmdir tmproot
end
class TestFileUtils end
include m
extend m
include FileUtils include FileUtils