* test/io/wait/test_io_wait.rb: use Socket.pair instaed of pipe.
Windows can only treat a socket. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70e9201610
commit
16846eb90c
@ -1,7 +1,7 @@
|
|||||||
Sat May 7 23:56:56 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sun May 8 00:13:05 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* test/io/wait/test_io_wait.rb: skip tests if the platform is
|
* test/io/wait/test_io_wait.rb: use Socket.pair instaed of pipe.
|
||||||
mswin.
|
Windows can only treat a socket.
|
||||||
|
|
||||||
Sat May 7 22:43:48 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat May 7 22:43:48 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'timeout'
|
require 'timeout'
|
||||||
|
require 'socket'
|
||||||
begin
|
begin
|
||||||
require 'io/wait'
|
require 'io/wait'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
@ -8,7 +9,7 @@ end
|
|||||||
class TestIOWait < Test::Unit::TestCase
|
class TestIOWait < Test::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@r, @w = IO.pipe
|
@r, @w = Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@ -17,21 +18,18 @@ class TestIOWait < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_nread
|
def test_nread
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
assert_equal 0, @r.nread
|
assert_equal 0, @r.nread
|
||||||
@w.syswrite "."
|
@w.syswrite "."
|
||||||
assert_equal 1, @r.nread
|
assert_equal 1, @r.nread
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nread_buffered
|
def test_nread_buffered
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
@w.syswrite ".\n!"
|
@w.syswrite ".\n!"
|
||||||
assert_equal ".\n", @r.read(2)
|
assert_equal ".\n", @r.read(2)
|
||||||
assert_equal 1, @r.nread
|
assert_equal 1, @r.nread
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ready?
|
def test_ready?
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
refute @r.ready?
|
refute @r.ready?
|
||||||
@w.syswrite "."
|
@w.syswrite "."
|
||||||
assert @r.ready?
|
assert @r.ready?
|
||||||
@ -44,27 +42,23 @@ class TestIOWait < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_wait
|
def test_wait
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
assert_nil @r.wait(0)
|
assert_nil @r.wait(0)
|
||||||
@w.syswrite "."
|
@w.syswrite "."
|
||||||
assert_equal @r, @r.wait(0)
|
assert_equal @r, @r.wait(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wait_buffered
|
def test_wait_buffered
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
@w.syswrite ".\n!"
|
@w.syswrite ".\n!"
|
||||||
assert_equal ".\n", @r.gets
|
assert_equal ".\n", @r.gets
|
||||||
assert_equal true, @r.wait(0)
|
assert_equal true, @r.wait(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wait_forever
|
def test_wait_forever
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
Thread.new { sleep 0.01; @w.syswrite "." }
|
Thread.new { sleep 0.01; @w.syswrite "." }
|
||||||
assert_equal @r, @r.wait
|
assert_equal @r, @r.wait
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wait_eof
|
def test_wait_eof
|
||||||
return if /mswin/ =~ RUBY_PLATFORM
|
|
||||||
Thread.new { sleep 0.01; @w.close }
|
Thread.new { sleep 0.01; @w.close }
|
||||||
assert_nil @r.wait
|
assert_nil @r.wait
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user