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

ruby-changes:43663

From: nobu <ko1@a...>
Date: Sun, 24 Jul 2016 00:04:17 +0900 (JST)
Subject: [ruby-changes:43663] nobu:r55736 (trunk): dtrace: suppress an empty line

nobu	2016-07-24 00:04:12 +0900 (Sun, 24 Jul 2016)

  New Revision: 55736

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

  Log:
    dtrace: suppress an empty line
    
    * test/dtrace/helper.rb (DTrace::TestCase#trap_probe): suppress
      an extra empty line to the controlling tty by dtrace on Darwin.

  Modified files:
    trunk/test/dtrace/helper.rb
Index: test/dtrace/helper.rb
===================================================================
--- test/dtrace/helper.rb	(revision 55735)
+++ test/dtrace/helper.rb	(revision 55736)
@@ -10,6 +10,16 @@ elsif (sudo = ENV["SUDO"]) and !sudo.emp https://github.com/ruby/ruby/blob/trunk/test/dtrace/helper.rb#L10
 else
   ok = false
 end
+if ok
+  case RUBY_PLATFORM
+  when /darwin/i
+    begin
+      require 'pty'
+    rescue LoadError
+      ok = false
+    end
+  end
+end
 ok &= (`dtrace -V` rescue false)
 module DTrace
   class TestCase < Test::Unit::TestCase
@@ -19,10 +29,20 @@ module DTrace https://github.com/ruby/ruby/blob/trunk/test/dtrace/helper.rb#L29
     when /solaris/i
       # increase bufsize to 8m (default 4m on Solaris)
       DTRACE_CMD = %w[dtrace -b 8m]
+    when /darwin/i
+      READ_PROBES = proc do |cmd|
+        PTY.spawn(*cmd) do |io, _|
+          break io.readlines
+        end
+      end
     end
 
     DTRACE_CMD ||= %w[dtrace]
 
+    READ_PROBES ||= proc do |cmd|
+      IO.popen(cmd, err: [:child, :out], &:readlines)
+    end
+
     case rubybin = EnvUtil.rubybin
     when /\/ruby-runner#{Regexp.quote(RbConfig::CONFIG["EXEEXT"])}\z/
       RUBYBIN = File.dirname(rubybin)+"/miniruby#{RbConfig::CONFIG["EXEEXT"]}"
@@ -51,9 +71,7 @@ module DTrace https://github.com/ruby/ruby/blob/trunk/test/dtrace/helper.rb#L71
         end
         cmd.unshift(sudo)
       end
-      probes = IO.popen(cmd, err: [:child, :out]) do |io|
-        io.readlines
-      end
+      probes = READ_PROBES.(cmd)
       d.close(true)
       rb.close(true)
       yield(d_path, rb_path, probes)

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

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