1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_file_exhaustive.rb: Test named pipe.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2015-04-10 10:32:38 +00:00
parent 1a688f001c
commit dec7415126
2 changed files with 28 additions and 3 deletions

View file

@ -1,3 +1,7 @@
Fri Apr 10 19:31:56 2015 Tanaka Akira <akr@fsij.org>
* test/ruby/test_file_exhaustive.rb: Test named pipe.
Fri Apr 10 19:10:34 2015 Koichi Sasada <ko1@atdot.net> Fri Apr 10 19:10:34 2015 Koichi Sasada <ko1@atdot.net>
* ext/objspace/objspace.c (setup_hash): unify common routine. * ext/objspace/objspace.c (setup_hash): unify common routine.

View file

@ -45,6 +45,13 @@ class TestFileExhaustive < Test::Unit::TestCase
open(file, "w") {|fh| fh << content } open(file, "w") {|fh| fh << content }
end end
if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
def make_fifo(file)
system("mkfifo", file)
assert $?.success?, "mkfifo fails"
end
end
def make_tmp_filename(prefix) def make_tmp_filename(prefix)
"#{@dir}/#{prefix}#{File.basename(__FILE__)}.#{$$}.test" "#{@dir}/#{prefix}#{File.basename(__FILE__)}.#{$$}.test"
end end
@ -141,10 +148,15 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_file.not_directory?(@nofile) assert_file.not_directory?(@nofile)
end end
def test_pipe_p ## xxx def test_pipe_p
assert_file.not_pipe?(@dir) assert_file.not_pipe?(@dir)
assert_file.not_pipe?(@file) assert_file.not_pipe?(@file)
assert_file.not_pipe?(@nofile) assert_file.not_pipe?(@nofile)
if self.respond_to? :make_fifo
fifo = make_tmp_filename("fifo")
make_fifo fifo
assert_file.pipe?(fifo)
end
end end
def test_symlink_p def test_symlink_p
@ -979,7 +991,11 @@ class TestFileExhaustive < Test::Unit::TestCase
def test_test def test_test
sleep(@time - Time.now + 1.1) sleep(@time - Time.now + 1.1)
make_file("foo", @file + "2") make_file("foo", @file + "2")
[@dir, @file, @zerofile, @symlinkfile, @hardlinkfile].compact.each do |f| if self.respond_to? :make_fifo
fifo = make_tmp_filename("fifo")
make_fifo fifo
end
[@dir, @file, @zerofile, @symlinkfile, @hardlinkfile, fifo].compact.each do |f|
assert_equal(File.atime(f), test(?A, f)) assert_equal(File.atime(f), test(?A, f))
assert_equal(File.ctime(f), test(?C, f)) assert_equal(File.ctime(f), test(?C, f))
assert_equal(File.mtime(f), test(?M, f)) assert_equal(File.mtime(f), test(?M, f))
@ -1076,9 +1092,14 @@ class TestFileExhaustive < Test::Unit::TestCase
assert(!(File::Stat.new(@file).directory?)) assert(!(File::Stat.new(@file).directory?))
end end
def test_stat_pipe_p ## xxx def test_stat_pipe_p
assert(!(File::Stat.new(@dir).pipe?)) assert(!(File::Stat.new(@dir).pipe?))
assert(!(File::Stat.new(@file).pipe?)) assert(!(File::Stat.new(@file).pipe?))
if self.respond_to? :make_fifo
fifo = make_tmp_filename("fifo")
make_fifo fifo
assert((File::Stat.new(fifo).pipe?))
end
end end
def test_stat_symlink_p def test_stat_symlink_p