mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make the test suite pass on real Android/Termux environment
Attempting to create a hard link raises EACCES
This commit is contained in:
parent
6527411f05
commit
2fd71112fb
7 changed files with 44 additions and 9 deletions
|
@ -13,7 +13,7 @@ describe "File.link" do
|
||||||
rm_r @link, @file
|
rm_r @link, @file
|
||||||
end
|
end
|
||||||
|
|
||||||
platform_is_not :windows do
|
platform_is_not :windows, :android do
|
||||||
it "link a file with another" do
|
it "link a file with another" do
|
||||||
File.link(@file, @link).should == 0
|
File.link(@file, @link).should == 0
|
||||||
File.should.exist?(@link)
|
File.should.exist?(@link)
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe "File::Stat#nlink" do
|
||||||
rm_r @link, @file
|
rm_r @link, @file
|
||||||
end
|
end
|
||||||
|
|
||||||
platform_is_not :windows do
|
platform_is_not :windows, :android do
|
||||||
it "returns the number of links to a file" do
|
it "returns the number of links to a file" do
|
||||||
File::Stat.new(@file).nlink.should == 1
|
File::Stat.new(@file).nlink.should == 1
|
||||||
File.link(@file, @link)
|
File.link(@file, @link)
|
||||||
|
|
|
@ -34,8 +34,16 @@ describe 'Socket#listen' do
|
||||||
@server.close
|
@server.close
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises Errno::EOPNOTSUPP' do
|
platform_is_not :android do
|
||||||
-> { @server.listen(1) }.should raise_error(Errno::EOPNOTSUPP)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,11 @@ describe :file_identical, shared: true do
|
||||||
touch(@file2) { |f| f.puts "file2" }
|
touch(@file2) { |f| f.puts "file2" }
|
||||||
|
|
||||||
rm_r @link
|
rm_r @link
|
||||||
File.link(@file1, @link)
|
begin
|
||||||
|
File.link(@file1, @link)
|
||||||
|
rescue Errno::EACCES
|
||||||
|
File.symlink(@file1, @link)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after :each do
|
after :each do
|
||||||
|
|
|
@ -72,8 +72,13 @@ class TestFileUtils < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_have_hardlink?
|
def check_have_hardlink?
|
||||||
File.link nil, nil
|
Dir.mktmpdir do |dir|
|
||||||
rescue NotImplementedError
|
Dir.chdir(dir) do
|
||||||
|
File.write "dummy", "dummy"
|
||||||
|
File.link "dummy", "hardlink"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue NotImplementedError, Errno::EACCES
|
||||||
return false
|
return false
|
||||||
rescue
|
rescue
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -345,9 +345,26 @@ class TestPathname < Test::Unit::TestCase
|
||||||
def has_symlink?
|
def has_symlink?
|
||||||
begin
|
begin
|
||||||
File.symlink("", "")
|
File.symlink("", "")
|
||||||
rescue NotImplementedError, Errno::EACCES
|
rescue NotImplementedError
|
||||||
return false
|
return false
|
||||||
rescue Errno::ENOENT
|
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
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -886,6 +903,7 @@ class TestPathname < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_make_link
|
def test_make_link
|
||||||
|
return if !has_hardlink?
|
||||||
with_tmpchdir('rubytest-pathname') {|dir|
|
with_tmpchdir('rubytest-pathname') {|dir|
|
||||||
open("a", "w") {|f| f.write "abc" }
|
open("a", "w") {|f| f.write "abc" }
|
||||||
Pathname("l").make_link(Pathname("a"))
|
Pathname("l").make_link(Pathname("a"))
|
||||||
|
|
|
@ -130,7 +130,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
@hardlinkfile = make_tmp_filename("hardlinkfile")
|
@hardlinkfile = make_tmp_filename("hardlinkfile")
|
||||||
begin
|
begin
|
||||||
File.link(regular_file, @hardlinkfile)
|
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
|
@hardlinkfile = nil
|
||||||
end
|
end
|
||||||
@hardlinkfile
|
@hardlinkfile
|
||||||
|
|
Loading…
Add table
Reference in a new issue