diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-02 03:07:17 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-02 03:07:17 +0000 |
commit | 4077b9b89dc1f139775774e59705677e54712cba (patch) | |
tree | 7a143699fc3117cd2827eb769b96f58e8259cae7 /test | |
parent | 2ae0c4c44bda180ec75ce8e571840e8b9667a7e5 (diff) | |
download | ruby-4077b9b89dc1f139775774e59705677e54712cba.tar.gz |
* lib/fileutils.rb: chmod/chmod_R with a string mode (e.g., "+x")
caused error in verbose mode.
* test/fileutils/test_fileutils.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/fileutils/test_fileutils.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 7de032145c..c1104f31ca 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -972,6 +972,27 @@ class TestFileUtils chmod_R 0700, 'tmp/dir' # to remove end if have_file_perm? + def test_chmod_verbose + check_singleton :chmod + + r, w = IO.pipe + stderr_back = $stderr + read, $stderr = IO.pipe + th = Thread.new { read.read } + + touch 'tmp/a' + chmod 0700, 'tmp/a', verbose: true + assert_equal 0700, File.stat('tmp/a').mode & 0777 + chmod 0500, 'tmp/a', verbose: true + assert_equal 0500, File.stat('tmp/a').mode & 0777 + + $stderr.close + lines = th.value.lines.map {|l| l.chomp } + assert_equal(["chmod 700 tmp/a", "chmod 500 tmp/a"], lines) + ensure + $stderr = stderr_back if stderr_back + end if have_file_perm? + # FIXME: How can I test this method? def test_chown check_singleton :chown |