diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-03-02 11:23:42 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-03-02 11:23:42 +0000 |
commit | 82019f272dff1990e7a273125a8414d056f6306d (patch) | |
tree | 4e5c2b970690abbe61eba9a9f6ec0c5eea04c0d4 /test/ruby | |
parent | dad70fa6a85990f61ec76a62456fde153e093af4 (diff) |
merge revision(s) a19228f8: [Backport #16979]
brace the fact that lchmod(2) can EOPNOTSUPP
Musl libc has this function as a tiny wrapper of fchmodat(3posix). On
the other hand Linux kernel does not support changing modes of a symlink.
The operation always fails with EOPNOTSUPP. This fchmodat behaviour is
defined in POSIX. We have to take care of such exceptions.
---
lib/fileutils.rb | 3 ++-
test/pathname/test_pathname.rb | 2 +-
test/ruby/test_notimp.rb | 19 ++++++++++++-------
3 files changed, 15 insertions(+), 9 deletions(-)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_notimp.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb index ddebb657bf..daa5a82d7b 100644 --- a/test/ruby/test_notimp.rb +++ b/test/ruby/test_notimp.rb @@ -13,11 +13,11 @@ class TestNotImplement < Test::Unit::TestCase def test_respond_to_lchmod assert_include(File.methods, :lchmod) - if /linux/ =~ RUBY_PLATFORM - assert_equal(false, File.respond_to?(:lchmod)) - end - if /freebsd/ =~ RUBY_PLATFORM + case RUBY_PLATFORM + when /freebsd/, /linux-musl/ assert_equal(true, File.respond_to?(:lchmod)) + when /linux/ + assert_equal(false, File.respond_to?(:lchmod)) end end @@ -57,9 +57,14 @@ class TestNotImplement < Test::Unit::TestCase File.open(f, "w") {} File.symlink f, g newmode = 0444 - File.lchmod newmode, "#{d}/g" - snew = File.lstat(g) - assert_equal(newmode, snew.mode & 0777) + begin + File.lchmod newmode, "#{d}/g" + rescue Errno::EOPNOTSUPP + skip $! + else + snew = File.lstat(g) + assert_equal(newmode, snew.mode & 0777) + end } end end |