summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 23:03:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 23:03:52 +0000
commit8f671120f1d99b47f28d67183855d634d006389a (patch)
tree5a6a943efb8bfb690d7cf5a5f05d2aa701d114ac /test/ruby/test_io.rb
parent65261bda4d964c081fc3a510bfaa094a7647e8bc (diff)
* 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
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb44
1 files changed, 22 insertions, 22 deletions
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