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

ruby-changes:35681

From: akr <ko1@a...>
Date: Thu, 2 Oct 2014 17:57:57 +0900 (JST)
Subject: [ruby-changes:35681] akr:r47763 (trunk): test_advice show OS and filesystem when failed.

akr	2014-10-02 17:57:44 +0900 (Thu, 02 Oct 2014)

  New Revision: 47763

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

  Log:
    test_advice show OS and filesystem when failed.

  Modified files:
    trunk/test/ruby/test_io.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 47762)
+++ test/ruby/test_io.rb	(revision 47763)
@@ -2447,13 +2447,48 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2447
     }
   end
 
+  def os_and_fs(path)
+    uname = Etc.uname
+    os = "#{uname[:sysname]} #{uname[:release]}"
+
+    fs = nil
+    if uname[:sysname] == 'Linux'
+      # [ruby-dev:45703] Old Linux's fadvice() doesn't work on tmpfs.
+      mount = `mount`
+      mountpoints = []
+      mount.scan(/ on (\S+) type (\S+) /) {
+        mountpoints << [$1, $2]
+      }
+      mountpoints.sort_by {|mountpoint, fstype| mountpoint.length }.reverse_each {|mountpoint, fstype|
+        if path == mountpoint
+          fs = fstype
+          break
+        end
+        mountpoint += "/" if %r{/\z} !~ mountpoint
+        if path.start_with?(mountpoint)
+          fs = fstype
+          break
+        end
+      }
+    end
+
+    if fs
+      "#{fs} on #{os}"
+    else
+      os
+    end
+  end
+
   def test_advise
     make_tempfile {|tf|
       assert_raise(ArgumentError, "no arguments") { tf.advise }
       %w{normal random sequential willneed dontneed noreuse}.map(&:to_sym).each do |adv|
         [[0,0], [0, 20], [400, 2]].each do |offset, len|
           open(tf.path) do |t|
-            assert_nil(t.advise(adv, offset, len))
+            ret = assert_nothing_raised(lambda { os_and_fs(tf.path) }) {
+              t.advise(adv, offset, len)
+            }
+            assert_nil(ret)
             assert_raise(ArgumentError, "superfluous arguments") do
               t.advise(adv, offset, len, offset)
             end

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

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