* lib/fileutils.rb (FileUtils#mode_to_s): Define mode_to_s() also
as singleton method, or FileUtils.chmod fails in verbose mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f5a6a2a7e0
commit
a6e3d4bea0
@ -1,3 +1,8 @@
|
||||
Tue Jul 9 15:53:51 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/fileutils.rb (FileUtils#mode_to_s): Define mode_to_s() also
|
||||
as singleton method, or FileUtils.chmod fails in verbose mode.
|
||||
|
||||
Tue Jul 9 15:16:02 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* test/fileutils/fileasserts.rb
|
||||
|
@ -952,6 +952,7 @@ module FileUtils
|
||||
def mode_to_s(mode) #:nodoc:
|
||||
mode.is_a?(String) ? mode : "%o" % mode
|
||||
end
|
||||
private_module_function :mode_to_s
|
||||
|
||||
#
|
||||
# Options: noop verbose
|
||||
|
@ -1024,7 +1024,6 @@ class TestFileUtils
|
||||
def test_chmod_verbose
|
||||
check_singleton :chmod
|
||||
|
||||
r, w = IO.pipe
|
||||
stderr_back = $stderr
|
||||
read, $stderr = IO.pipe
|
||||
th = Thread.new { read.read }
|
||||
@ -1042,6 +1041,23 @@ class TestFileUtils
|
||||
$stderr = stderr_back if stderr_back
|
||||
end if have_file_perm?
|
||||
|
||||
def test_s_chmod_verbose
|
||||
output_back = FileUtils.instance_variable_get(:@fileutils_output)
|
||||
read, write = IO.pipe
|
||||
FileUtils.instance_variable_set(:@fileutils_output, write)
|
||||
th = Thread.new { read.read }
|
||||
|
||||
touch 'tmp/a'
|
||||
FileUtils.chmod 0700, 'tmp/a', verbose: true
|
||||
assert_equal 0700, File.stat('tmp/a').mode & 0777
|
||||
|
||||
write.close
|
||||
lines = th.value.lines.map {|l| l.chomp }
|
||||
assert_equal(["chmod 700 tmp/a"], lines)
|
||||
ensure
|
||||
FileUtils.instance_variable_set(:@fileutils_output, output_back) if output_back
|
||||
end if have_file_perm?
|
||||
|
||||
# FIXME: How can I test this method?
|
||||
def test_chown
|
||||
check_singleton :chown
|
||||
|
Loading…
x
Reference in New Issue
Block a user