ruby-changes:29801
From: knu <ko1@a...>
Date: Tue, 9 Jul 2013 16:02:19 +0900 (JST)
Subject: [ruby-changes:29801] knu:r41853 (trunk): * lib/fileutils.rb (FileUtils#mode_to_s): Define mode_to_s() also
knu 2013-07-09 16:02:04 +0900 (Tue, 09 Jul 2013) New Revision: 41853 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41853 Log: * lib/fileutils.rb (FileUtils#mode_to_s): Define mode_to_s() also as singleton method, or FileUtils.chmod fails in verbose mode. Modified files: trunk/ChangeLog trunk/lib/fileutils.rb trunk/test/fileutils/test_fileutils.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 41852) +++ ChangeLog (revision 41853) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jul 9 15:53:51 2013 Akinori MUSHA <knu@i...> + + * 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@i...> * test/fileutils/fileasserts.rb Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 41852) +++ lib/fileutils.rb (revision 41853) @@ -952,6 +952,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L952 def mode_to_s(mode) #:nodoc: mode.is_a?(String) ? mode : "%o" % mode end + private_module_function :mode_to_s # # Options: noop verbose Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 41852) +++ test/fileutils/test_fileutils.rb (revision 41853) @@ -1024,7 +1024,6 @@ class TestFileUtils https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L1024 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 https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L1041 $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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/