diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 44 |
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 |