diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-04 17:22:08 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-04 17:22:08 +0000 |
commit | a0011cd54d1da03ef7097092a6cdf2daaa33fc35 (patch) | |
tree | 7da8901e3e5f22df81850583d376b91efd6d454d /test/fileutils/test_fileutils.rb | |
parent | 45116b6a6d7c3c0ef927863ed947cce4146ea3f1 (diff) | |
download | ruby-a0011cd54d1da03ef7097092a6cdf2daaa33fc35.tar.gz |
* lib/fileutils.rb (FileUtils.chmod{,_R}): Enhance the symbolic
mode parser to support the permission symbols u/g/o and multiple
actions as defined in SUS, so that chmod("g=o+w", file) works as
expected. Invalid symbolic modes are now rejected with
ArgumentError.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils/test_fileutils.rb')
-rw-r--r-- | test/fileutils/test_fileutils.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 1317a5b043..ea9c38bfe9 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -932,6 +932,12 @@ class TestFileUtils check_singleton :chmod touch 'tmp/a' + chmod "u=wrx,g=rx,o=x", 'tmp/a' + assert_equal 0751, File.stat('tmp/a').mode & 07777 + chmod "g+w-x", 'tmp/a' + assert_equal 0761, File.stat('tmp/a').mode & 07777 + chmod "o+r,g=o+w,o-r,u-o", 'tmp/a' # 761 => 763 => 773 => 771 => 671 + assert_equal 0671, File.stat('tmp/a').mode & 07777 chmod "u=wrx,g=,o=", 'tmp/a' assert_equal 0700, File.stat('tmp/a').mode & 0777 chmod "u=rx,go=", 'tmp/a' @@ -956,6 +962,26 @@ class TestFileUtils assert_equal 0500, File.stat('tmp/a').mode & 07777 end + assert_raises_with_message(ArgumentError, /invalid\b.*\bfile mode/) { + chmod "a", 'tmp/a' + } + + assert_raises_with_message(ArgumentError, /invalid\b.*\bfile mode/) { + chmod "x+a", 'tmp/a' + } + + assert_raises_with_message(ArgumentError, /invalid\b.*\bfile mode/) { + chmod "u+z", 'tmp/a' + } + + assert_raises_with_message(ArgumentError, /invalid\b.*\bfile mode/) { + chmod ",+x", 'tmp/a' + } + + assert_raises_with_message(ArgumentError, /invalid\b.*\bfile mode/) { + chmod "755", 'tmp/a' + } + end if have_file_perm? |