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

ruby-changes:31442

From: akr <ko1@a...>
Date: Sun, 3 Nov 2013 23:09:41 +0900 (JST)
Subject: [ruby-changes:31442] akr:r43521 (trunk): * sample/test.rb: Make temporary file names unique.

akr	2013-11-03 23:09:35 +0900 (Sun, 03 Nov 2013)

  New Revision: 43521

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

  Log:
    * sample/test.rb: Make temporary file names unique.

  Modified files:
    trunk/ChangeLog
    trunk/sample/test.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43520)
+++ ChangeLog	(revision 43521)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  3 23:06:51 2013  Tanaka Akira  <akr@f...>
+
+	* sample/test.rb: Make temporary file names unique.
+
 Sun Nov  3 20:41:17 2013  Tanaka Akira  <akr@f...>
 
 	* test/xmlrpc: Wrap definitions by TestXMLRPC module.
Index: sample/test.rb
===================================================================
--- sample/test.rb	(revision 43520)
+++ sample/test.rb	(revision 43521)
@@ -645,7 +645,8 @@ end https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L645
 
 test_check "while/until";
 
-tmp = open("while_tmp", "w")
+while_tmp = "while_tmp.#{$$}"
+tmp = open(while_tmp, "w")
 tmp.print "tvi925\n";
 tmp.print "tvi920\n";
 tmp.print "vt100\n";
@@ -655,7 +656,7 @@ tmp.close https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L656
 
 # test break
 
-tmp = open("while_tmp", "r")
+tmp = open(while_tmp, "r")
 test_ok(tmp.kind_of?(File))
 
 while line = tmp.gets()
@@ -667,7 +668,7 @@ tmp.close https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L668
 
 # test next
 $bad = false
-tmp = open("while_tmp", "r")
+tmp = open(while_tmp, "r")
 while line = tmp.gets()
   next if /vt100/ =~ line
   $bad = 1 if /vt100/ =~ line
@@ -677,7 +678,7 @@ tmp.close https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L678
 
 # test redo
 $bad = false
-tmp = open("while_tmp", "r")
+tmp = open(while_tmp, "r")
 while line = tmp.gets()
   lastline = line
   line = line.gsub(/vt100/, 'VT100')
@@ -703,7 +704,7 @@ test_ok(sum == 220) https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L704
 
 # test interval
 $bad = false
-tmp = open("while_tmp", "r")
+tmp = open(while_tmp, "r")
 while line = tmp.gets()
   break if 3
   case line
@@ -714,8 +715,8 @@ end https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L715
 test_ok(!$bad)
 tmp.close
 
-File.unlink "while_tmp" or `/bin/rm -f "while_tmp"`
-test_ok(!File.exist?("while_tmp"))
+File.unlink while_tmp or `/bin/rm -f "#{while_tmp}"`
+test_ok(!File.exist?(while_tmp))
 
 i = 0
 until i>4
@@ -1969,21 +1970,22 @@ test_check "system" https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L1970
 test_ok(`echo foobar` == "foobar\n")
 test_ok(`./miniruby -e 'print "foobar"'` == 'foobar')
 
-tmp = open("script_tmp", "w")
+script_tmp = "script_tmp.#{$$}"
+tmp = open(script_tmp, "w")
 tmp.print "print $zzz\n";
 tmp.close
 
-test_ok(`./miniruby -s script_tmp -zzz` == 'true')
-test_ok(`./miniruby -s script_tmp -zzz=555` == '555')
+test_ok(`./miniruby -s #{script_tmp} -zzz` == 'true')
+test_ok(`./miniruby -s #{script_tmp} -zzz=555` == '555')
 
-tmp = open("script_tmp", "w")
+tmp = open(script_tmp, "w")
 tmp.print "#! /usr/local/bin/ruby -s\n";
 tmp.print "print $zzz\n";
 tmp.close
 
-test_ok(`./miniruby script_tmp -zzz=678` == '678')
+test_ok(`./miniruby #{script_tmp} -zzz=678` == '678')
 
-tmp = open("script_tmp", "w")
+tmp = open(script_tmp, "w")
 tmp.print "this is a leading junk\n";
 tmp.print "#! /usr/local/bin/ruby -s\n";
 tmp.print "print $zzz\n";
@@ -1991,18 +1993,18 @@ tmp.print "__END__\n"; https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L1993
 tmp.print "this is a trailing junk\n";
 tmp.close
 
-test_ok(`./miniruby -x script_tmp` == '')
-test_ok(`./miniruby -x script_tmp -zzz=555` == '555')
+test_ok(`./miniruby -x #{script_tmp}` == '')
+test_ok(`./miniruby -x #{script_tmp} -zzz=555` == '555')
 
-tmp = open("script_tmp", "w")
+tmp = open(script_tmp, "w")
 for i in 1..5
   tmp.print i, "\n"
 end
 tmp.close
 
-`./miniruby -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
+`./miniruby -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' #{script_tmp}`
 done = true
-tmp = open("script_tmp", "r")
+tmp = open(script_tmp, "r")
 while tmp.gets
   if $_.to_i % 5 != 0
     done = false
@@ -2012,8 +2014,8 @@ end https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L2014
 tmp.close
 test_ok(done)
 
-File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
-File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
+File.unlink script_tmp or `/bin/rm -f "#{script_tmp}"`
+File.unlink "#{script_tmp}.bak" or `/bin/rm -f "#{script_tmp}.bak"`
 
 test_check "const"
 TEST1 = 1

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

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