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

ruby-changes:26273

From: nobu <ko1@a...>
Date: Wed, 12 Dec 2012 03:09:27 +0900 (JST)
Subject: [ruby-changes:26273] nobu:r38330 (trunk): test.rb: show messages in one line

nobu	2012-12-12 03:09:10 +0900 (Wed, 12 Dec 2012)

  New Revision: 38330

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

  Log:
    test.rb: show messages in one line
    
    * sample/test.rb (Progress#initialize): add --verbose option and show
      messages in one line unless --verbose is given.

  Modified files:
    trunk/ChangeLog
    trunk/sample/test.rb
    trunk/tool/rubytest.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38329)
+++ ChangeLog	(revision 38330)
@@ -1,3 +1,8 @@
+Wed Dec 12 03:09:05 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* sample/test.rb (Progress#initialize): add --verbose option and show
+	  messages in one line unless --verbose is given.
+
 Wed Dec 12 01:47:02 2012  Shugo Maeda  <shugo@r...>
 
 	* eval.c (rb_using_refinement): make the method table of an iclass
Index: sample/test.rb
===================================================================
--- sample/test.rb	(revision 38329)
+++ sample/test.rb	(revision 38330)
@@ -8,6 +8,7 @@
   def initialize
     @color = nil
     @quiet = nil
+    @verbose = nil
     ARGV.each do |arg|
       case arg
       when /\A--color(?:=(?:always|(auto)|(never)|(.*)))?\z/
@@ -15,9 +16,12 @@
         @color = $1 ? nil : !$2
       when /\A-(q|-quiet)\z/
         @quiet = true
+      when /\A-(v|-verbose)\z/
+        @verbose = true
       end
     end
     @tty = STDERR.tty? && !STDOUT.tty? && /dumb/ !~ ENV["TERM"]
+    @eol = @tty && !@verbose ? "\r\e[K\r" : "\n"
     case @color
     when nil
       @color = @tty
@@ -44,9 +48,9 @@
   end
   def finish_string
     if @quiet
-      "\n"
+      @eol
     else
-      "#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}\n"
+      "#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}#{@eol}"
     end
   end
   def pass
Index: tool/rubytest.rb
===================================================================
--- tool/rubytest.rb	(revision 38329)
+++ tool/rubytest.rb	(revision 38330)
@@ -1,6 +1,6 @@
 #! ./miniruby
 
-exit if defined?(CROSS_COMPILING)
+exit if defined?(CROSS_COMPILING) and CROSS_COMPILING
 ruby = ENV["RUBY"]
 unless ruby
   load './rbconfig.rb'

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

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