[前][次][番号順一覧][スレッド一覧]

ruby-changes:26835

From: nobu <ko1@a...>
Date: Sun, 20 Jan 2013 22:26:10 +0900 (JST)
Subject: [ruby-changes:26835] nobu:r38887 (trunk): test_logger.rb: uset tmpfile

nobu	2013-01-20 22:25:58 +0900 (Sun, 20 Jan 2013)

  New Revision: 38887

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38887

  Log:
    test_logger.rb: uset tmpfile
    
    * test/logger/test_logger.rb (TestLogDevice#test_shifting_size):
      should not create working file in the current directory.

  Modified files:
    trunk/test/logger/test_logger.rb

Index: test/logger/test_logger.rb
===================================================================
--- test/logger/test_logger.rb	(revision 38886)
+++ test/logger/test_logger.rb	(revision 38887)
@@ -126,7 +126,7 @@ class TestLogger < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/logger/test_logger.rb#L126
     end
     logger.formatter = o
     line = log_raw(logger, :info, "foo")
-    assert_equal("<<INFO-foo>>\n", line)
+    assert_equal("<""<INFO-foo>>\n", line)
   end
 
   def test_initialize
@@ -354,11 +354,13 @@ class TestLogDevice < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/logger/test_logger.rb#L354
   end
 
   def test_shifting_size
-    logfile = File.basename(__FILE__) + '_1.log'
+    tmpfile = Tempfile.new([File.basename(__FILE__, '.*'), '_1.log'])
+    logfile = tmpfile.path
     logfile0 = logfile + '.0'
     logfile1 = logfile + '.1'
     logfile2 = logfile + '.2'
     logfile3 = logfile + '.3'
+    tmpfile.close(true)
     File.unlink(logfile) if File.exist?(logfile)
     File.unlink(logfile0) if File.exist?(logfile0)
     File.unlink(logfile1) if File.exist?(logfile1)
@@ -386,11 +388,13 @@ class TestLogDevice < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/logger/test_logger.rb#L388
     File.unlink(logfile1)
     File.unlink(logfile2)
 
-    logfile = File.basename(__FILE__) + '_2.log'
+    tmpfile = Tempfile.new([File.basename(__FILE__, '.*'), '_2.log'])
+    logfile = tmpfile.path
     logfile0 = logfile + '.0'
     logfile1 = logfile + '.1'
     logfile2 = logfile + '.2'
     logfile3 = logfile + '.3'
+    tmpfile.close(true)
     logger = Logger.new(logfile, 4, 150)
     logger.error("0" * 15)
     assert(File.exist?(logfile))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]