From c75df796d875b02d7b97974c7fe840f0a9de171f Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 28 Oct 2021 18:54:01 +0200 Subject: Update to ruby/spec@21a48d9 --- spec/ruby/command_line/backtrace_limit_spec.rb | 4 ++-- spec/ruby/command_line/dash_upper_w_spec.rb | 33 +++++++++++--------------- spec/ruby/command_line/dash_w_spec.rb | 6 +++++ spec/ruby/command_line/fixtures/backtrace.rb | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) (limited to 'spec/ruby/command_line') diff --git a/spec/ruby/command_line/backtrace_limit_spec.rb b/spec/ruby/command_line/backtrace_limit_spec.rb index c0b243841e..56afa8efef 100644 --- a/spec/ruby/command_line/backtrace_limit_spec.rb +++ b/spec/ruby/command_line/backtrace_limit_spec.rb @@ -9,7 +9,7 @@ ruby_version_is "3.0" do out.should == <<-MSG top -/fixtures/backtrace.rb:2:in `a': unhandled exception +/fixtures/backtrace.rb:2:in `a': oops (RuntimeError) \tfrom /fixtures/backtrace.rb:6:in `b' \tfrom /fixtures/backtrace.rb:10:in `c' \t ... 2 levels... @@ -23,7 +23,7 @@ top out.should == <<-MSG full_message -/fixtures/backtrace.rb:2:in `a': unhandled exception +/fixtures/backtrace.rb:2:in `a': oops (RuntimeError) \tfrom /fixtures/backtrace.rb:6:in `b' \tfrom /fixtures/backtrace.rb:10:in `c' \t ... 2 levels... diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb index 1b36a1cc22..cbb040a8dd 100644 --- a/spec/ruby/command_line/dash_upper_w_spec.rb +++ b/spec/ruby/command_line/dash_upper_w_spec.rb @@ -19,34 +19,29 @@ describe "The -W command line option with 2" do it_behaves_like :command_line_verbose, "-W2" end +# Regarding the defaults, see core/warning/element_reference_spec.rb ruby_version_is "2.7" do + describe "The -W command line option with :deprecated" do + it "enables deprecation warnings" do + ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n" + end + end + describe "The -W command line option with :no-deprecated" do it "suppresses deprecation warnings" do - result = ruby_exe('$; = ""', options: '-w', args: '2>&1') - result.should =~ /is deprecated/ - - result = ruby_exe('$; = ""', options: '-w -W:no-deprecated', args: '2>&1') - result.should == "" + ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n" end end - describe "The -W command line option with :no-experimental" do - before do - ruby_version_is ""..."3.0" do - @src = 'case [0, 1]; in [a, b]; end' - end - - ruby_version_is "3.0" do - @src = 'warn "This is experimental warning.", category: :experimental' - end + describe "The -W command line option with :experimental" do + it "enables experimental warnings" do + ruby_exe('p Warning[:experimental]', options: '-W:experimental').should == "true\n" end + end + describe "The -W command line option with :no-experimental" do it "suppresses experimental warnings" do - result = ruby_exe(@src, args: '2>&1') - result.should =~ /is experimental/ - - result = ruby_exe(@src, options: '-W:no-experimental', args: '2>&1') - result.should == "" + ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n" end end end diff --git a/spec/ruby/command_line/dash_w_spec.rb b/spec/ruby/command_line/dash_w_spec.rb index 1d93e0347b..c262df12cc 100644 --- a/spec/ruby/command_line/dash_w_spec.rb +++ b/spec/ruby/command_line/dash_w_spec.rb @@ -3,4 +3,10 @@ require_relative 'shared/verbose' describe "The -w command line option" do it_behaves_like :command_line_verbose, "-w" + + ruby_version_is "2.7" do + it "enables both deprecated and experimental warnings" do + ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n" + end + end end diff --git a/spec/ruby/command_line/fixtures/backtrace.rb b/spec/ruby/command_line/fixtures/backtrace.rb index 19ad638d35..99acae95c8 100644 --- a/spec/ruby/command_line/fixtures/backtrace.rb +++ b/spec/ruby/command_line/fixtures/backtrace.rb @@ -1,5 +1,5 @@ def a - raise + raise 'oops' end def b -- cgit v1.2.3