mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_file_exhaustive.rb (assert_integer): may not Fixnum.
* test/ruby/test_file_exhaustive.rb (test_stat, test_readable_p) (test_readable_real_p, test_world_readable_p, test_writable_p) (test_writable_real_p, test_world_writable_p, test_executable_p) (test_executable_real_p, test_owned_p, test_chmod, test_lchmod) (test_umask, test_stat_readable_p, test_stat_readable_real_p) (test_stat_world_readable_p, test_stat_writable_p) (test_stat_writable_real_p, test_stat_world_writable_p) (test_stat_executable_p, test_stat_executable_real_p) (test_stat_owned_p): mode, owner and group can't rely on cygwin. * test/ruby/test_file_exhaustive.rb (test_stat_init): test hard link on Windows too. * test/ruby/test_file_exhaustive.rb (test_test): struct stat dosn't have sub second mtime on cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
10b1c8298a
commit
e4f8e61ddd
1 changed files with 32 additions and 29 deletions
|
@ -51,7 +51,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def assert_integer(n)
|
||||
assert(n.is_a?(Fixnum), n.inspect + " is not Fixnum.")
|
||||
assert(n.is_a?(Integer), n.inspect + " is not Fixnum.")
|
||||
end
|
||||
|
||||
def assert_integer_or_nil(n)
|
||||
|
@ -75,7 +75,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
assert_integer_or_nil(fs1.rdev_minor)
|
||||
assert_integer(fs1.ino)
|
||||
assert_integer(fs1.mode)
|
||||
unless /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
unless /emx/ =~ RUBY_PLATFORM
|
||||
assert_equal(@hardlinkfile ? 2 : 1, fs1.nlink)
|
||||
end
|
||||
assert_integer(fs1.uid)
|
||||
|
@ -139,7 +139,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_readable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0200, @file)
|
||||
assert(!(File.readable?(@file)))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -148,7 +148,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_readable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0200, @file)
|
||||
assert(!(File.readable_real?(@file)))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -157,7 +157,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_world_readable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0006, @file)
|
||||
assert(File.world_readable?(@file))
|
||||
File.chmod(0060, @file)
|
||||
|
@ -168,7 +168,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_writable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0400, @file)
|
||||
assert(!(File.writable?(@file)))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -177,7 +177,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_writable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0400, @file)
|
||||
assert(!(File.writable_real?(@file)))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -186,7 +186,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_world_writable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0006, @file)
|
||||
assert(File.world_writable?(@file))
|
||||
File.chmod(0060, @file)
|
||||
|
@ -197,7 +197,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_executable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0100, @file)
|
||||
assert(File.executable?(@file))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -206,7 +206,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_executable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0100, @file)
|
||||
assert(File.executable_real?(@file))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -235,7 +235,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_owned_p ## xxx
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
assert(File.owned?(@file))
|
||||
assert(File.grpowned?(@file))
|
||||
end
|
||||
|
@ -296,7 +296,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_chmod
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
assert_equal(1, File.chmod(0444, @file))
|
||||
assert_equal(0444, File.stat(@file).mode % 01000)
|
||||
assert_equal(0, File.new(@file).chmod(0222))
|
||||
|
@ -306,7 +306,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_lchmod
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
assert_equal(1, File.lchmod(0444, @file))
|
||||
assert_equal(0444, File.stat(@file).mode % 01000)
|
||||
File.lchmod(0600, @file)
|
||||
|
@ -362,7 +362,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_umask
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
prev = File.umask(0777)
|
||||
assert_equal(0777, File.umask)
|
||||
open(@nofile, "w") { }
|
||||
|
@ -382,6 +382,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
assert_equal("foo", File.basename("foo"))
|
||||
assert_equal("foo", File.basename("foo", ".ext"))
|
||||
assert_equal("foo", File.basename("foo.ext", ".ext"))
|
||||
assert_equal("foo", File.basename("foo.ext", ".*"))
|
||||
end
|
||||
|
||||
def test_dirname
|
||||
|
@ -477,13 +478,15 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
assert_equal(false, test(?-, @dir, @file))
|
||||
assert_equal(true, test(?-, @file, @file))
|
||||
assert_equal(true, test(?=, @file, @file))
|
||||
assert_equal(false, test(?=, @file, @file + "2"))
|
||||
assert_equal(false, test(?>, @file, @file))
|
||||
assert_equal(false, test(?>, @file, @file + "2"))
|
||||
assert_equal(true, test(?>, @file + "2", @file))
|
||||
assert_equal(false, test(?<, @file, @file))
|
||||
assert_equal(true, test(?<, @file, @file + "2"))
|
||||
assert_equal(false, test(?<, @file + "2", @file))
|
||||
unless /cygwin/ =~ RUBY_PLATFORM
|
||||
assert_equal(false, test(?=, @file, @file + "2"))
|
||||
assert_equal(false, test(?>, @file, @file + "2"))
|
||||
assert_equal(true, test(?>, @file + "2", @file))
|
||||
assert_equal(true, test(?<, @file, @file + "2"))
|
||||
assert_equal(false, test(?<, @file + "2", @file))
|
||||
end
|
||||
assert_raise(ArgumentError) { test }
|
||||
assert_raise(Errno::ENOENT) { test(?A, @nofile) }
|
||||
assert_raise(ArgumentError) { test(?a) }
|
||||
|
@ -507,7 +510,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
assert_integer_or_nil(fs1.rdev_minor)
|
||||
assert_integer(fs1.ino)
|
||||
assert_integer(fs1.mode)
|
||||
unless /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
unless /emx/ =~ RUBY_PLATFORM
|
||||
assert_equal(@hardlinkfile ? 2 : 1, fs1.nlink)
|
||||
end
|
||||
assert_integer(fs1.uid)
|
||||
|
@ -569,7 +572,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_readable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0200, @file)
|
||||
assert(!(File::Stat.new(@file).readable?))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -577,7 +580,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_readable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0200, @file)
|
||||
assert(!(File::Stat.new(@file).readable_real?))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -585,7 +588,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_world_readable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0006, @file)
|
||||
assert(File::Stat.new(@file).world_readable?)
|
||||
File.chmod(0060, @file)
|
||||
|
@ -595,7 +598,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_writable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0400, @file)
|
||||
assert(!(File::Stat.new(@file).writable?))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -603,7 +606,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_writable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0400, @file)
|
||||
assert(!(File::Stat.new(@file).writable_real?))
|
||||
File.chmod(0600, @file)
|
||||
|
@ -611,7 +614,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_world_writable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0006, @file)
|
||||
assert(File::Stat.new(@file).world_writable?)
|
||||
File.chmod(0060, @file)
|
||||
|
@ -621,7 +624,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_executable_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0100, @file)
|
||||
assert(File::Stat.new(@file).executable?)
|
||||
File.chmod(0600, @file)
|
||||
|
@ -629,7 +632,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_executable_real_p
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
File.chmod(0100, @file)
|
||||
assert(File::Stat.new(@file).executable_real?)
|
||||
File.chmod(0600, @file)
|
||||
|
@ -654,7 +657,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_stat_owned_p ## xxx
|
||||
return if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
|
||||
return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM
|
||||
assert(File::Stat.new(@file).owned?)
|
||||
assert(File::Stat.new(@file).grpowned?)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue