summaryrefslogtreecommitdiff
path: root/tool/lib/test
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-09-03 15:47:49 +0200
committerBenoit Daloze <eregontp@gmail.com>2022-09-10 13:14:18 +0200
commit92b907d12d6de6f74f1efa6d8cd4fed8fa50763e (patch)
tree43b4bd3af6b38695a2c8c8051f215cd16459b9e1 /tool/lib/test
parent5e39b3b844d5601541deb7cb0648d88cc6fdc080 (diff)
Enable deprecation warnings for test-all
* So deprecated methods/constants/functions are dealt with early, instead of many tests breaking suddenly when removing a deprecated method/constant/function. * Follows https://bugs.ruby-lang.org/issues/17591
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6321
Diffstat (limited to 'tool/lib/test')
-rw-r--r--tool/lib/test/unit.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index 8cb6d8f651..b2190843c8 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -1,5 +1,20 @@
# frozen_string_literal: true
+# Enable deprecation warnings for test-all, so deprecated methods/constants/functions are dealt with early.
+Warning[:deprecated] = true
+
+if ENV['BACKTRACE_FOR_DEPRECATION_WARNINGS']
+ Warning.extend Module.new {
+ def warn(message, category: nil, **kwargs)
+ if category == :deprecated and $stderr.respond_to?(:puts)
+ $stderr.puts nil, message, caller, nil
+ else
+ super
+ end
+ end
+ }
+end
+
require_relative '../envutil'
require_relative '../colorize'
require_relative '../leakchecker'