From dec741512647226d7bf3dee328d91c5fd87f10f9 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 10 Apr 2015 10:32:38 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 ++++ test/ruby/test_file_exhaustive.rb | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79f8cf192b..869606da50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Apr 10 19:31:56 2015 Tanaka Akira + + * test/ruby/test_file_exhaustive.rb: Test named pipe. + Fri Apr 10 19:10:34 2015 Koichi Sasada * ext/objspace/objspace.c (setup_hash): unify common routine. diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index b347e53d16..142adac43b 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -45,6 +45,13 @@ class TestFileExhaustive < Test::Unit::TestCase open(file, "w") {|fh| fh << content } 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) "#{@dir}/#{prefix}#{File.basename(__FILE__)}.#{$$}.test" end @@ -141,10 +148,15 @@ class TestFileExhaustive < Test::Unit::TestCase assert_file.not_directory?(@nofile) end - def test_pipe_p ## xxx + def test_pipe_p assert_file.not_pipe?(@dir) assert_file.not_pipe?(@file) 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 def test_symlink_p @@ -979,7 +991,11 @@ class TestFileExhaustive < Test::Unit::TestCase def test_test sleep(@time - Time.now + 1.1) 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.ctime(f), test(?C, f)) assert_equal(File.mtime(f), test(?M, f)) @@ -1076,9 +1092,14 @@ class TestFileExhaustive < Test::Unit::TestCase assert(!(File::Stat.new(@file).directory?)) end - def test_stat_pipe_p ## xxx + def test_stat_pipe_p assert(!(File::Stat.new(@dir).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 def test_stat_symlink_p