[前][次][番号順一覧][スレッド一覧]

ruby-changes:38132

From: akr <ko1@a...>
Date: Fri, 10 Apr 2015 19:52:49 +0900 (JST)
Subject: [ruby-changes:38132] akr:r50213 (trunk): * test/ruby/test_file_exhaustive.rb: Test socket.

akr	2015-04-10 19:52:29 +0900 (Fri, 10 Apr 2015)

  New Revision: 50213

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50213

  Log:
    * test/ruby/test_file_exhaustive.rb: Test socket.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_file_exhaustive.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50212)
+++ ChangeLog	(revision 50213)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 10 19:34:24 2015  Tanaka Akira  <akr@f...>
+
+	* test/ruby/test_file_exhaustive.rb: Test socket.
+
 Fri Apr 10 19:38:46 2015  Koichi Sasada  <ko1@a...>
 
 	* test/objspace/test_objspace.rb: remove debug prints.
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 50212)
+++ test/ruby/test_file_exhaustive.rb	(revision 50213)
@@ -1,6 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1
 require "test/unit"
 require "fileutils"
 require "tmpdir"
+require "socket"
 
 class TestFileExhaustive < Test::Unit::TestCase
   DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i]
@@ -167,10 +168,16 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L168
     assert_file.not_symlink?(@nofile)
   end
 
-  def test_socket_p ## xxx
+  def test_socket_p
     assert_file.not_socket?(@dir)
     assert_file.not_socket?(@file)
     assert_file.not_socket?(@nofile)
+    if defined? UNIXServer
+      socket = make_tmp_filename("socket")
+      UNIXServer.open(socket) {|sock|
+        assert_file.socket?(socket)
+      }
+    end
   end
 
   def test_blockdev_p ## xxx
@@ -995,7 +1002,11 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1002
       fifo = make_tmp_filename("fifo")
       make_fifo fifo
     end
-    [@dir, @file, @zerofile, @symlinkfile, @hardlinkfile, fifo].compact.each do |f|
+    if defined? UNIXServer
+      socket = make_tmp_filename("socket")
+      UNIXServer.open(socket).close
+    end
+    [@dir, @file, @zerofile, @symlinkfile, @hardlinkfile, fifo, socket].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))
@@ -1114,9 +1125,15 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1125
     assert(!(File::Stat.new(@hardlinkfile).symlink?)) if @hardlinkfile
   end
 
-  def test_stat_socket_p ## xxx
+  def test_stat_socket_p
     assert(!(File::Stat.new(@dir).socket?))
     assert(!(File::Stat.new(@file).socket?))
+    if defined? UNIXServer
+      socket = make_tmp_filename("socket")
+      UNIXServer.open(socket) {|sock|
+        assert(File::Stat.new(socket).socket?)
+      }
+    end
   end
 
   def test_stat_blockdev_p ## xxx

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]