mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_file_exhaustive.rb: POSIX
* test/ruby/test_file_exhaustive.rb (POSIX): flag for test of POSIX-like filesystems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fe294d75fe
commit
c305a5aac2
1 changed files with 28 additions and 27 deletions
|
@ -5,6 +5,7 @@ require "socket"
|
||||||
|
|
||||||
class TestFileExhaustive < Test::Unit::TestCase
|
class TestFileExhaustive < Test::Unit::TestCase
|
||||||
DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i]
|
DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i]
|
||||||
|
POSIX = /cygwin|mswin|bccwin|mingw|emx/ !~ RUBY_PLATFORM
|
||||||
|
|
||||||
def assert_incompatible_encoding
|
def assert_incompatible_encoding
|
||||||
d = "\u{3042}\u{3044}".encode("utf-16le")
|
d = "\u{3042}\u{3044}".encode("utf-16le")
|
||||||
|
@ -69,7 +70,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
|
|
||||||
def suidfile
|
def suidfile
|
||||||
return @suidfile if defined? @suidfile
|
return @suidfile if defined? @suidfile
|
||||||
if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
|
if POSIX
|
||||||
@suidfile = make_tmp_filename("suidfile")
|
@suidfile = make_tmp_filename("suidfile")
|
||||||
make_file("", @suidfile)
|
make_file("", @suidfile)
|
||||||
File.chmod 04500, @suidfile
|
File.chmod 04500, @suidfile
|
||||||
|
@ -81,7 +82,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
|
|
||||||
def sgidfile
|
def sgidfile
|
||||||
return @sgidfile if defined? @sgidfile
|
return @sgidfile if defined? @sgidfile
|
||||||
if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
|
if POSIX
|
||||||
@sgidfile = make_tmp_filename("sgidfile")
|
@sgidfile = make_tmp_filename("sgidfile")
|
||||||
make_file("", @sgidfile)
|
make_file("", @sgidfile)
|
||||||
File.chmod 02500, @sgidfile
|
File.chmod 02500, @sgidfile
|
||||||
|
@ -93,7 +94,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
|
|
||||||
def stickyfile
|
def stickyfile
|
||||||
return @stickyfile if defined? @stickyfile
|
return @stickyfile if defined? @stickyfile
|
||||||
if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
|
if POSIX
|
||||||
@stickyfile = make_tmp_filename("stickyfile")
|
@stickyfile = make_tmp_filename("stickyfile")
|
||||||
Dir.mkdir(@stickyfile)
|
Dir.mkdir(@stickyfile)
|
||||||
File.chmod 01500, @stickyfile
|
File.chmod 01500, @stickyfile
|
||||||
|
@ -127,7 +128,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
|
|
||||||
def fifo
|
def fifo
|
||||||
return @fifo if defined? @fifo
|
return @fifo if defined? @fifo
|
||||||
if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
|
if POSIX
|
||||||
fn = make_tmp_filename("fifo")
|
fn = make_tmp_filename("fifo")
|
||||||
system("mkfifo", fn)
|
system("mkfifo", fn)
|
||||||
assert $?.success?, "mkfifo fails"
|
assert $?.success?, "mkfifo fails"
|
||||||
|
@ -307,7 +308,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_readable_p
|
def test_readable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0200, regular_file)
|
File.chmod(0200, regular_file)
|
||||||
assert_file.not_readable?(regular_file)
|
assert_file.not_readable?(regular_file)
|
||||||
|
@ -317,7 +318,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_readable_real_p
|
def test_readable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0200, regular_file)
|
File.chmod(0200, regular_file)
|
||||||
assert_file.not_readable_real?(regular_file)
|
assert_file.not_readable_real?(regular_file)
|
||||||
|
@ -327,7 +328,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_world_readable_p
|
def test_world_readable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0006, regular_file)
|
File.chmod(0006, regular_file)
|
||||||
assert_file.world_readable?(regular_file)
|
assert_file.world_readable?(regular_file)
|
||||||
File.chmod(0060, regular_file)
|
File.chmod(0060, regular_file)
|
||||||
|
@ -338,7 +339,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_writable_p
|
def test_writable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0400, regular_file)
|
File.chmod(0400, regular_file)
|
||||||
assert_file.not_writable?(regular_file)
|
assert_file.not_writable?(regular_file)
|
||||||
|
@ -348,7 +349,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_writable_real_p
|
def test_writable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0400, regular_file)
|
File.chmod(0400, regular_file)
|
||||||
assert_file.not_writable_real?(regular_file)
|
assert_file.not_writable_real?(regular_file)
|
||||||
|
@ -358,7 +359,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_world_writable_p
|
def test_world_writable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0006, regular_file)
|
File.chmod(0006, regular_file)
|
||||||
assert_file.world_writable?(regular_file)
|
assert_file.world_writable?(regular_file)
|
||||||
File.chmod(0060, regular_file)
|
File.chmod(0060, regular_file)
|
||||||
|
@ -369,7 +370,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_executable_p
|
def test_executable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0100, regular_file)
|
File.chmod(0100, regular_file)
|
||||||
assert_file.executable?(regular_file)
|
assert_file.executable?(regular_file)
|
||||||
File.chmod(0600, regular_file)
|
File.chmod(0600, regular_file)
|
||||||
|
@ -378,7 +379,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_executable_real_p
|
def test_executable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0100, regular_file)
|
File.chmod(0100, regular_file)
|
||||||
assert_file.executable_real?(regular_file)
|
assert_file.executable_real?(regular_file)
|
||||||
File.chmod(0600, regular_file)
|
File.chmod(0600, regular_file)
|
||||||
|
@ -407,13 +408,13 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_owned_p
|
def test_owned_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert_file.owned?(regular_file)
|
assert_file.owned?(regular_file)
|
||||||
assert_file.not_owned?(notownedfile) if notownedfile
|
assert_file.not_owned?(notownedfile) if notownedfile
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_grpowned_p ## xxx
|
def test_grpowned_p ## xxx
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert_file.grpowned?(regular_file)
|
assert_file.grpowned?(regular_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -499,7 +500,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chmod
|
def test_chmod
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert_equal(1, File.chmod(0444, regular_file))
|
assert_equal(1, File.chmod(0444, regular_file))
|
||||||
assert_equal(0444, File.stat(regular_file).mode % 01000)
|
assert_equal(0444, File.stat(regular_file).mode % 01000)
|
||||||
assert_equal(0, File.open(regular_file) {|f| f.chmod(0222)})
|
assert_equal(0, File.open(regular_file) {|f| f.chmod(0222)})
|
||||||
|
@ -509,7 +510,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lchmod
|
def test_lchmod
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert_equal(1, File.lchmod(0444, regular_file))
|
assert_equal(1, File.lchmod(0444, regular_file))
|
||||||
assert_equal(0444, File.stat(regular_file).mode % 01000)
|
assert_equal(0444, File.stat(regular_file).mode % 01000)
|
||||||
File.lchmod(0600, regular_file)
|
File.lchmod(0600, regular_file)
|
||||||
|
@ -586,7 +587,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_umask
|
def test_umask
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
prev = File.umask(0777)
|
prev = File.umask(0777)
|
||||||
assert_equal(0777, File.umask)
|
assert_equal(0777, File.umask)
|
||||||
open(nofile, "w") { }
|
open(nofile, "w") { }
|
||||||
|
@ -1274,7 +1275,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_readable_p
|
def test_stat_readable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0200, regular_file)
|
File.chmod(0200, regular_file)
|
||||||
assert(!(File::Stat.new(regular_file).readable?))
|
assert(!(File::Stat.new(regular_file).readable?))
|
||||||
|
@ -1283,7 +1284,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_readable_real_p
|
def test_stat_readable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0200, regular_file)
|
File.chmod(0200, regular_file)
|
||||||
assert(!(File::Stat.new(regular_file).readable_real?))
|
assert(!(File::Stat.new(regular_file).readable_real?))
|
||||||
|
@ -1292,7 +1293,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_world_readable_p
|
def test_stat_world_readable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0006, regular_file)
|
File.chmod(0006, regular_file)
|
||||||
assert(File::Stat.new(regular_file).world_readable?)
|
assert(File::Stat.new(regular_file).world_readable?)
|
||||||
File.chmod(0060, regular_file)
|
File.chmod(0060, regular_file)
|
||||||
|
@ -1302,7 +1303,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_writable_p
|
def test_stat_writable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0400, regular_file)
|
File.chmod(0400, regular_file)
|
||||||
assert(!(File::Stat.new(regular_file).writable?))
|
assert(!(File::Stat.new(regular_file).writable?))
|
||||||
|
@ -1311,7 +1312,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_writable_real_p
|
def test_stat_writable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
return if Process.euid == 0
|
return if Process.euid == 0
|
||||||
File.chmod(0400, regular_file)
|
File.chmod(0400, regular_file)
|
||||||
assert(!(File::Stat.new(regular_file).writable_real?))
|
assert(!(File::Stat.new(regular_file).writable_real?))
|
||||||
|
@ -1320,7 +1321,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_world_writable_p
|
def test_stat_world_writable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0006, regular_file)
|
File.chmod(0006, regular_file)
|
||||||
assert(File::Stat.new(regular_file).world_writable?)
|
assert(File::Stat.new(regular_file).world_writable?)
|
||||||
File.chmod(0060, regular_file)
|
File.chmod(0060, regular_file)
|
||||||
|
@ -1330,7 +1331,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_executable_p
|
def test_stat_executable_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0100, regular_file)
|
File.chmod(0100, regular_file)
|
||||||
assert(File::Stat.new(regular_file).executable?)
|
assert(File::Stat.new(regular_file).executable?)
|
||||||
File.chmod(0600, regular_file)
|
File.chmod(0600, regular_file)
|
||||||
|
@ -1338,7 +1339,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_executable_real_p
|
def test_stat_executable_real_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
File.chmod(0100, regular_file)
|
File.chmod(0100, regular_file)
|
||||||
assert(File::Stat.new(regular_file).executable_real?)
|
assert(File::Stat.new(regular_file).executable_real?)
|
||||||
File.chmod(0600, regular_file)
|
File.chmod(0600, regular_file)
|
||||||
|
@ -1363,13 +1364,13 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_owned_p
|
def test_stat_owned_p
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert(File::Stat.new(regular_file).owned?)
|
assert(File::Stat.new(regular_file).owned?)
|
||||||
assert(!File::Stat.new(notownedfile).owned?) if notownedfile
|
assert(!File::Stat.new(notownedfile).owned?) if notownedfile
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat_grpowned_p ## xxx
|
def test_stat_grpowned_p ## xxx
|
||||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
return if !POSIX
|
||||||
assert(File::Stat.new(regular_file).grpowned?)
|
assert(File::Stat.new(regular_file).grpowned?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue