[前][次][番号順一覧][スレッド一覧]

ruby-changes:63332

From: Yusuke <ko1@a...>
Date: Mon, 12 Oct 2020 21:47:13 +0900 (JST)
Subject: [ruby-changes:63332] 2fd71112fb (master): Make the test suite pass on real Android/Termux environment

https://git.ruby-lang.org/ruby.git/commit/?id=2fd71112fb

From 2fd71112fb5b1aafa5b243c7ac5713cfae7fc23c Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Mon, 12 Oct 2020 21:26:05 +0900
Subject: Make the test suite pass on real Android/Termux environment

Attempting to create a hard link raises EACCES

diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb
index cc63c76..a5d5b48 100644
--- a/spec/ruby/core/file/link_spec.rb
+++ b/spec/ruby/core/file/link_spec.rb
@@ -13,7 +13,7 @@ describe "File.link" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/link_spec.rb#L13
     rm_r @link, @file
   end
 
-  platform_is_not :windows do
+  platform_is_not :windows, :android do
     it "link a file with another" do
       File.link(@file, @link).should == 0
       File.should.exist?(@link)
diff --git a/spec/ruby/core/file/stat/nlink_spec.rb b/spec/ruby/core/file/stat/nlink_spec.rb
index 2dd0bff..7143923 100644
--- a/spec/ruby/core/file/stat/nlink_spec.rb
+++ b/spec/ruby/core/file/stat/nlink_spec.rb
@@ -11,7 +11,7 @@ describe "File::Stat#nlink" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/stat/nlink_spec.rb#L11
     rm_r @link, @file
   end
 
-  platform_is_not :windows do
+  platform_is_not :windows, :android do
     it "returns the number of links to a file" do
       File::Stat.new(@file).nlink.should == 1
       File.link(@file, @link)
diff --git a/spec/ruby/library/socket/socket/listen_spec.rb b/spec/ruby/library/socket/socket/listen_spec.rb
index 5de70d6..986d9f8 100644
--- a/spec/ruby/library/socket/socket/listen_spec.rb
+++ b/spec/ruby/library/socket/socket/listen_spec.rb
@@ -34,8 +34,16 @@ describe 'Socket#listen' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/listen_spec.rb#L34
         @server.close
       end
 
-      it 'raises Errno::EOPNOTSUPP' do
-        -> { @server.listen(1) }.should raise_error(Errno::EOPNOTSUPP)
+      platform_is_not :android do
+        it 'raises Errno::EOPNOTSUPP' do
+          -> { @server.listen(1) }.should raise_error(Errno::EOPNOTSUPP)
+        end
+      end
+
+      platform_is :android do
+        it 'raises Errno::EACCES' do
+          -> { @server.listen(1) }.should raise_error(Errno::EACCES)
+        end
       end
     end
 
diff --git a/spec/ruby/shared/file/identical.rb b/spec/ruby/shared/file/identical.rb
index ecc2172..b7a2904 100644
--- a/spec/ruby/shared/file/identical.rb
+++ b/spec/ruby/shared/file/identical.rb
@@ -9,7 +9,11 @@ describe :file_identical, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/file/identical.rb#L9
     touch(@file2) { |f| f.puts "file2" }
 
     rm_r @link
-    File.link(@file1, @link)
+    begin
+      File.link(@file1, @link)
+    rescue Errno::EACCES
+      File.symlink(@file1, @link)
+    end
   end
 
   after :each do
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index 8a546cc..fbc8e3d 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -72,8 +72,13 @@ class TestFileUtils < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L72
     end
 
     def check_have_hardlink?
-      File.link nil, nil
-    rescue NotImplementedError
+      Dir.mktmpdir do |dir|
+        Dir.chdir(dir) do
+          File.write "dummy", "dummy"
+          File.link "dummy", "hardlink"
+        end
+      end
+    rescue NotImplementedError, Errno::EACCES
       return false
     rescue
       return true
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index dadcd13..43cef48 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -345,9 +345,26 @@ class TestPathname < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L345
   def has_symlink?
     begin
       File.symlink("", "")
-    rescue NotImplementedError, Errno::EACCES
+    rescue NotImplementedError
       return false
     rescue Errno::ENOENT
+      return false
+    rescue Errno::EACCES
+      return false
+    end
+    return true
+  end
+
+  def has_hardlink?
+    begin
+      with_tmpchdir("rubytest-pathname") {|dir|
+        File.write("dummy", "dummy")
+        File.link("dummy", "hardlink")
+      }
+    rescue NotImplementedError
+      return false
+    rescue Errno::EACCES
+      return false
     end
     return true
   end
@@ -886,6 +903,7 @@ class TestPathname < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L903
   end
 
   def test_make_link
+    return if !has_hardlink?
     with_tmpchdir('rubytest-pathname') {|dir|
       open("a", "w") {|f| f.write "abc" }
       Pathname("l").make_link(Pathname("a"))
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 975bcb6..ac11e0c 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -130,7 +130,7 @@ class TestFileExhaustive < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L130
     @hardlinkfile = make_tmp_filename("hardlinkfile")
     begin
       File.link(regular_file, @hardlinkfile)
-    rescue NotImplementedError, Errno::EINVAL	# EINVAL for Windows Vista
+    rescue NotImplementedError, Errno::EINVAL, Errno::EACCES   # EINVAL for Windows Vista, EACCES for Android Termux
       @hardlinkfile = nil
     end
     @hardlinkfile
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]