ruby-changes:38128
From: akr <ko1@a...>
Date: Fri, 10 Apr 2015 19:33:04 +0900 (JST)
Subject: [ruby-changes:38128] akr:r50209 (trunk): * test/ruby/test_file_exhaustive.rb: Test named pipe.
akr 2015-04-10 19:32:38 +0900 (Fri, 10 Apr 2015) New Revision: 50209 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50209 Log: * test/ruby/test_file_exhaustive.rb: Test named pipe. Modified files: trunk/ChangeLog trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50208) +++ ChangeLog (revision 50209) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Apr 10 19:31:56 2015 Tanaka Akira <akr@f...> + + * test/ruby/test_file_exhaustive.rb: Test named pipe. + Fri Apr 10 19:10:34 2015 Koichi Sasada <ko1@a...> * ext/objspace/objspace.c (setup_hash): unify common routine. Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 50208) +++ test/ruby/test_file_exhaustive.rb (revision 50209) @@ -45,6 +45,13 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L45 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::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L148 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::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L991 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::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1092 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/