diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-17 14:23:56 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-17 14:23:56 +0000 |
commit | 7bf12316a1716c2116908c494e9e259dc39eb8a5 (patch) | |
tree | 2f81c0bbe4f4ef543a83f29d90ebed54a459d7df /test | |
parent | ede915ce25611fc10e34b712b94bdc0b16b8ab6a (diff) | |
download | ruby-7bf12316a1716c2116908c494e9e259dc39eb8a5.tar.gz |
* test/rexml/test_sax.rb: don't use thread and sleep to avoid slow test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rexml/test_sax.rb | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/test/rexml/test_sax.rb b/test/rexml/test_sax.rb index e93ce8d1e7..c5ac21ca3d 100644 --- a/test/rexml/test_sax.rb +++ b/test/rexml/test_sax.rb @@ -221,29 +221,22 @@ class SAX2Tester < Test::Unit::TestCase def test_socket require 'socket' - $port = 12345 - - Thread.new{ - server = TCPServer.new('127.0.0.1', $port) - while (session = server.accept) - session << '<foo>' - Thread.stop + port = 12345 + + server = TCPServer.new('127.0.0.1', port) + socket = TCPSocket.new('127.0.0.1', port) + + ok = false + session = server.accept + session << '<foo>' + parser = REXML::Parsers::SAX2Parser.new(socket) + Fiber.new do + parser.listen(:start_element) do + ok = true + Fiber.yield end - } - sleep 1 #to be sure that server is running - @socket = TCPSocket.new('127.0.0.1',$port) - - ok = false - - test = Thread.new{ - parser = REXML::Parsers::SAX2Parser.new @socket - parser.listen( :start_element ) { - ok = true - } parser.parse - Thread.stop - } - sleep 1 #to be sure that server is running + end.resume assert(ok) end |