From fe380789101b80574e62250f16ed3f1e3acf782b Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 27 Feb 2014 08:19:46 +0000 Subject: test_scanf.rb: use tmpefile * test/scanf/test_scanf.rb (TestIOScanf): use different name for each tests, to get rid of weird errors on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/scanf/test_scanf.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/scanf/test_scanf.rb b/test/scanf/test_scanf.rb index 84d8788ae1..3f09b1d330 100644 --- a/test/scanf/test_scanf.rb +++ b/test/scanf/test_scanf.rb @@ -7,7 +7,7 @@ require 'scanf.rb' require 'test/unit' -require 'tmpdir' +require 'tempfile' # Comment out either of these lines to skip those tests. @@ -311,15 +311,13 @@ class TestIOScanf include Scanf extend ScanfTests - tmpfilename = "#{Dir.tmpdir}/iotest.dat.#{$$}" - self.each_test do |test, i| define_method("test_#{i}") do || - File.open(tmpfilename, "w") {|fh| fh.print test[1]} - File.open(tmpfilename, "r") { |fh| + Tempfile.create("iotest.dat") do |fh| + fh.print test[1] + fh.rewind assert_equal(test[2], fh.scanf(test[0])) - } - File.delete(tmpfilename) + end end end end -- cgit v1.2.3