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

ruby-changes:72426

From: Nobuyoshi <ko1@a...>
Date: Tue, 5 Jul 2022 16:36:19 +0900 (JST)
Subject: [ruby-changes:72426] 1b34bd07c1 (master): Separate failed output option

https://git.ruby-lang.org/ruby.git/commit/?id=1b34bd07c1

From 1b34bd07c18068228188a72f94662cceac50f30e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 5 Jul 2022 09:31:32 +0900
Subject: Separate failed output option

It is unrelated to `GlobOption` at all.
---
 tool/lib/test/unit.rb | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index ba3685d1ef..ade0e62f6f 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -200,8 +200,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L200
           "  " + (s =~ /[\s|&<>$()]/ ? s.inspect : s)
         }.join("\n")
 
-        @failed_output = options[:stderr_on_failure] ? $stderr : $stdout
-
         @options = options
       end
 
@@ -1121,9 +1119,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L1119
         parser.on '-x', '--exclude REGEXP', 'Exclude test files on pattern.' do |pattern|
           (options[:reject] ||= []) << pattern
         end
-        parser.on '--stderr-on-failure', 'Use stderr to print failure messages' do
-          options[:stderr_on_failure] = true
-        end
       end
 
       def complement_test_name f, orig_f
@@ -1183,6 +1178,23 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L1178
       end
     end
 
+    module OutputOption # :nodoc: all
+      def setup_options(parser, options)
+        super
+        parser.separator "output options:"
+        parser.on '--stderr-on-failure', 'Use stderr to print failure messages' do
+          options[:stderr_on_failure] = true
+        end
+      end
+
+      def process_args(args = [])
+        return @options if @options
+        options = super
+        @failed_output = options[:stderr_on_failure] ? $stderr : $stdout
+        options
+      end
+    end
+
     module GCOption # :nodoc: all
       def setup_options(parser, options)
         super
@@ -1668,6 +1680,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L1680
       prepend Test::Unit::Statistics
       prepend Test::Unit::Skipping
       prepend Test::Unit::GlobOption
+      prepend Test::Unit::OutputOption
       prepend Test::Unit::RepeatOption
       prepend Test::Unit::LoadPathOption
       prepend Test::Unit::GCOption
-- 
cgit v1.2.1


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

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