From 8f671120f1d99b47f28d67183855d634d006389a Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 20 Apr 2013 23:03:52 +0000 Subject: * test/csv/test_features.rb, test/logger/test_logger.rb test/mkmf/test_have_macro.rb, test/net/http/test_http.rb, test/openssl/test_config.rb, test/psych/test_encoding.rb, test/psych/test_exception.rb, test/psych/test_psych.rb, test/psych/test_tainted.rb, test/readline/test_readline.rb, test/rexml/test_contrib.rb, test/ruby/test_autoload.rb, test/ruby/test_beginendblock.rb, test/ruby/test_exception.rb, test/ruby/test_file.rb, test/ruby/test_io.rb, test/ruby/test_marshal.rb, test/ruby/test_process.rb, test/ruby/test_require.rb, test/ruby/test_rubyoptions.rb, test/syslog/test_syslog_logger.rb, test/webrick/test_httpauth.rb, test/zlib/test_zlib.rb: Use Tempfile.create. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'test/ruby/test_io.rb') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index b968bb6fcd..58cae7e291 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2204,7 +2204,7 @@ End return if /x86_64-linux/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform pad=0 - Tempfile.open(self.class.name) do |f| + Tempfile.create(self.class.name) do |f| r, w = IO.pipe pid = fork do r.close @@ -2230,7 +2230,6 @@ End Process.kill :TERM, pid Process.waitpid2(pid) - f.close(true) end end @@ -2240,7 +2239,7 @@ End start = 12 len = 34 sysid = 0 - Tempfile.open(self.class.name) do |f| + Tempfile.create(self.class.name) do |f| r, w = IO.pipe pid = fork do r.close @@ -2270,14 +2269,13 @@ End end def test_fcntl_dupfd - Tempfile.open(self.class.name) do |f| + Tempfile.create(self.class.name) do |f| fd = f.fcntl(Fcntl::F_DUPFD, 63) begin assert_operator(fd, :>=, 63) ensure IO.for_fd(fd).close end - f.unlink end end @@ -2396,23 +2394,25 @@ End end def test_race_between_read - file = Tempfile.new("test") - path = file.path - file.close - write_file = File.open(path, "wt") - read_file = File.open(path, "rt") - - threads = [] - 10.times do |i| - threads << Thread.new {write_file.print(i)} - threads << Thread.new {read_file.read} - end - threads.each {|t| t.join} - assert(true, "[ruby-core:37197]") - ensure - read_file.close - write_file.close - file.close! + Tempfile.create("test") {|file| + begin + path = file.path + file.close + write_file = File.open(path, "wt") + read_file = File.open(path, "rt") + + threads = [] + 10.times do |i| + threads << Thread.new {write_file.print(i)} + threads << Thread.new {read_file.read} + end + threads.each {|t| t.join} + assert(true, "[ruby-core:37197]") + ensure + read_file.close + write_file.close + end + } end def test_warn -- cgit v1.2.3