ruby-changes:64860
From: Nobuyoshi <ko1@a...>
Date: Wed, 13 Jan 2021 18:13:05 +0900 (JST)
Subject: [ruby-changes:64860] 6f6dfdcc68 (master): Make warning values consistent [Bug #17523]
https://git.ruby-lang.org/ruby.git/commit/?id=6f6dfdcc68 From 6f6dfdcc685077f0f85dcdd63843ecfc0f6fbfb6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 9 Jan 2021 16:52:51 +0900 Subject: Make warning values consistent [Bug #17523] They should be affected, as well as `$VERBOSE`, by `-w`/`-W` options, not only in the main script but in scripts loaded by `-r` option too. diff --git a/ruby.c b/ruby.c index 949b4b4..5bac96b 100644 --- a/ruby.c +++ b/ruby.c @@ -1510,6 +1510,8 @@ ruby_opt_init(ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1510 } } + rb_warning_category_update(opt->warn.mask, opt->warn.set); + Init_ext(); /* load statically linked extensions before rubygems */ rb_call_builtin_inits(); ruby_init_prelude(); @@ -1946,7 +1948,6 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1948 ruby_set_script_name(progname); rb_parser_set_options(parser, opt->do_print, opt->do_loop, opt->do_line, opt->do_split); - rb_warning_category_update(opt->warn.mask, opt->warn.set); ast = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); } else { @@ -2186,7 +2187,6 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L2187 } rb_parser_set_options(parser, opt->do_print, opt->do_loop, opt->do_line, opt->do_split); - rb_warning_category_update(opt->warn.mask, opt->warn.set); if (NIL_P(f)) { f = rb_str_new(0, 0); rb_enc_associate(f, enc); diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 214b89c..b783194 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -85,6 +85,15 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L85 assert_in_out_err(%w(-W -e) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-We) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-e) + ['p Warning[:deprecated]'], "", %w(false), []) + code = 'puts "#{$VERBOSE}:#{Warning[:deprecated]}:#{Warning[:experimental]}"' + Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) do |t| + t.puts code + t.close + assert_in_out_err(["-r#{t.path}", '-e', code], "", %w(false:false:true false:false:true), []) + assert_in_out_err(["-r#{t.path}", '-w', '-e', code], "", %w(true:true:true true:true:true), []) + assert_in_out_err(["-r#{t.path}", '-W:deprecated', '-e', code], "", %w(false:true:true false:true:true), []) + assert_in_out_err(["-r#{t.path}", '-W:no-experimental', '-e', code], "", %w(false:false:false false:false:false), []) + end ensure ENV['RUBYOPT'] = save_rubyopt end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/