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

ruby-changes:5900

From: usa <ko1@a...>
Date: Wed, 18 Jun 2008 16:30:10 +0900 (JST)
Subject: [ruby-changes:5900] Ruby:r17408 (trunk): * test/ruby/test_argf.rb: support NO_SAFE_RENAME platforms.

usa	2008-06-18 16:28:24 +0900 (Wed, 18 Jun 2008)

  New Revision: 17408

  Modified files:
    trunk/test/ruby/test_argf.rb

  Log:
    * test/ruby/test_argf.rb: support NO_SAFE_RENAME platforms.
    
    * test/ruby/test_argf.rb: now tempfiles are binmode'ed to test tell/pos/etc.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_argf.rb?r1=17408&r2=17407&diff_format=u

Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 17407)
+++ test/ruby/test_argf.rb	(revision 17408)
@@ -7,14 +7,17 @@
 class TestArgf < Test::Unit::TestCase
   def setup
     @t1 = Tempfile.new("foo")
+    @t1.binmode
     @t1.puts "1"
     @t1.puts "2"
     @t1.close
     @t2 = Tempfile.new("bar")
+    @t2.binmode
     @t2.puts "3"
     @t2.puts "4"
     @t2.close
     @t3 = Tempfile.new("baz")
+    @t3.binmode
     @t3.puts "5"
     @t3.puts "6"
     @t3.close
@@ -47,6 +50,10 @@
     f.close unless !f || f.closed?
   end
 
+  def no_safe_rename
+    /cygwin|mswin|mingw|bccwin/ =~ RUBY_PLATFORM
+  end
+
   def test_argf
     ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
       a = ARGF
@@ -203,9 +210,15 @@
       w.puts "  puts line.chomp + '.new'"
       w.puts "end"
       w.close
-      assert_match(/Can't rename .* to .*: .*. skipping file/, e.read) #'
-      assert_equal("", r.read)
-      assert_equal("foo\nbar\nbaz\n", File.read(t.path))
+      if no_safe_rename
+        assert_equal("", e.read)
+        assert_equal("", r.read)
+        assert_equal("foo.new\nbar.new\nbaz.new\n", File.read(t.path))
+      else
+        assert_match(/Can't rename .* to .*: .*. skipping file/, e.read) #'
+        assert_equal("", r.read)
+        assert_equal("foo\nbar\nbaz\n", File.read(t.path))
+      end
     end
   end
 
@@ -218,9 +231,13 @@
       w.puts "  puts line.chomp + '.new'"
       w.puts "end"
       w.close
-      assert_equal("", e.read)
-      assert_equal("", r.read)
-      assert_equal("foo.new\nbar.new\nbaz.new\n", File.read(t.path))
+      if no_safe_rename
+        assert_match(/Can't do inplace edit without backup/, e.read) #'
+      else
+        assert_equal("", e.read)
+        assert_equal("", r.read)
+        assert_equal("foo.new\nbar.new\nbaz.new\n", File.read(t.path))
+      end
     end
   end
 
@@ -284,6 +301,7 @@
   def test_tell
     ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
       begin
+        ARGF.binmode
         loop do
           p ARGF.tell
           p ARGF.gets
@@ -642,13 +660,9 @@
   end
 
   def test_binmode
-    r = ""
-    @tmps.each do |f|
-      r << IO.read(f.path, mode:"rb")
-    end
     ruby('-e', "ARGF.binmode; STDOUT.binmode; puts ARGF.read", @t1.path, @t2.path, @t3.path) do |f|
       f.binmode
-      assert_equal(r, f.read)
+      assert_equal("1\n2\n3\n4\n5\n6\n", f.read)
     end
   end
 

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

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