diff options
author | nagachika <nagachika@ruby-lang.org> | 2020-06-27 12:29:42 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2020-06-27 12:29:42 +0900 |
commit | 799c5766a4dc215d139d2c26ac68636f43a64fbf (patch) | |
tree | 03f4330b6617fde2167ad398b18047b19c399b3e /test | |
parent | d8a32b146561a0ddd3e60da9863a082b7e7725db (diff) | |
download | ruby-799c5766a4dc215d139d2c26ac68636f43a64fbf.tar.gz |
merge revision(s) a19228f878d955eaf2cce086bcf53f46fdf894b9: [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.
Diffstat (limited to 'test')
-rw-r--r-- | test/pathname/test_pathname.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_notimp.rb | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 792510bdfb..2ce32a6c12 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -818,7 +818,7 @@ class TestPathname < Test::Unit::TestCase old = path.lstat.mode begin path.lchmod(0444) - rescue NotImplementedError + rescue NotImplementedError, Errno::EOPNOTSUPP next end assert_equal(0444, path.lstat.mode & 0777) diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb index b069154cfc..e13db692b5 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 |