summaryrefslogtreecommitdiff
path: root/tool/lib/test
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2022-01-26 01:34:57 +0900
committerKoichi Sasada <ko1@atdot.net>2022-01-26 09:56:09 +0900
commitcac6fe90236c8541059edc74080d50c49be7ea87 (patch)
treea1d36f09845f61904bc5d0f89985412c5014aa12 /tool/lib/test
parent142d5db1122cf28f1a5563c421f169923a9f2e79 (diff)
add `--stderr-on-failure` option to test-all
Now all failure messages are printed to stdout. This option makes all failure messages printed into stderr.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5483
Diffstat (limited to 'tool/lib/test')
-rw-r--r--tool/lib/test/unit.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index 3bb2692b43..f4f44f8010 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -199,6 +199,9 @@ module Test
@help = "\n" + orig_args.map { |s|
" " + (s =~ /[\s|&<>$()]/ ? s.inspect : s)
}.join("\n")
+
+ @failed_output = options[:stderr_on_failure] ? $stderr : $stdout
+
@options = options
end
@@ -1004,7 +1007,7 @@ module Test
end
first, msg = msg.split(/$/, 2)
first = sprintf("%3d) %s", @report_count += 1, first)
- $stdout.print(sep, @colorize.decorate(first, color), msg, "\n")
+ @failed_output.print(sep, @colorize.decorate(first, color), msg, "\n")
sep = nil
end
report.clear
@@ -1106,6 +1109,9 @@ module Test
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