From 182b6148692f94263dd2adc575b9398c8da0306a Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 20 Dec 2010 21:25:49 +0000 Subject: * test/rexml/test_contrib.rb (ContribTester#test_pos): should not use fixed path name for tests. [ruby-dev:42827] * test/rexml/test_sax.rb (SAX2Tester#test_socket): should not use fixed port for tests. [ruby-dev:42828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_contrib.rb | 16 ++++++++-------- test/rexml/test_sax.rb | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'test/rexml') diff --git a/test/rexml/test_contrib.rb b/test/rexml/test_contrib.rb index f448b0fe4a..3bbaa083b3 100644 --- a/test/rexml/test_contrib.rb +++ b/test/rexml/test_contrib.rb @@ -74,7 +74,7 @@ DELIMITER EOF doc = REXML::Document.new source doc.write(out="") - assert(out[/>'>/] != nil, "Couldn't find >'>") + assert(out[/>\'>/] != nil, "Couldn't find >'>") assert(out[/\]>/] != nil, "Couldn't find ]>") end @@ -512,7 +512,8 @@ EOL end def test_pos - testfile = "/tmp/tidal#{$$}" + require 'tempfile' + testfile = Tempfile.new("tidal") testdata = %Q{
760 @@ -521,13 +522,12 @@ EOL } - File.open(testfile, 'w') do |f| - f.puts testdata + testfile.puts testdata + testfile.rewind + assert_nothing_raised do + d = REXML::Document.new(testfile) end - File.open(testfile) do |f| - d = REXML::Document.new(f) - end - #File.unlink(testfile) + testfile.close(true) end def test_deep_clone diff --git a/test/rexml/test_sax.rb b/test/rexml/test_sax.rb index c5ac21ca3d..569270ceb1 100644 --- a/test/rexml/test_sax.rb +++ b/test/rexml/test_sax.rb @@ -221,10 +221,8 @@ class SAX2Tester < Test::Unit::TestCase def test_socket require 'socket' - port = 12345 - - server = TCPServer.new('127.0.0.1', port) - socket = TCPSocket.new('127.0.0.1', port) + server = TCPServer.new('127.0.0.1', 0) + socket = TCPSocket.new('127.0.0.1', server.addr[1]) ok = false session = server.accept -- cgit v1.2.3