diff options
Diffstat (limited to 'spec/ruby/command_line')
| -rw-r--r-- | spec/ruby/command_line/backtrace_limit_spec.rb | 44 | ||||
| -rw-r--r-- | spec/ruby/command_line/dash_upper_u_spec.rb | 7 | ||||
| -rw-r--r-- | spec/ruby/command_line/dash_upper_w_spec.rb | 33 | ||||
| -rw-r--r-- | spec/ruby/command_line/dash_v_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/command_line/dash_w_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/command_line/feature_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/command_line/fixtures/bin/embedded_ruby.txt | 2 | ||||
| -rw-r--r-- | spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rb | bin | 90 -> 121 bytes | |||
| -rw-r--r-- | spec/ruby/command_line/fixtures/freeze_flag_two_literals.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/command_line/rubyopt_spec.rb | 30 |
10 files changed, 65 insertions, 65 deletions
diff --git a/spec/ruby/command_line/backtrace_limit_spec.rb b/spec/ruby/command_line/backtrace_limit_spec.rb index bc40a542a0..56afa8efef 100644 --- a/spec/ruby/command_line/backtrace_limit_spec.rb +++ b/spec/ruby/command_line/backtrace_limit_spec.rb @@ -1,46 +1,48 @@ require_relative '../spec_helper' -describe "The --backtrace-limit command line option" do - it "limits top-level backtraces to a given number of entries" do - file = fixture(__FILE__ , "backtrace.rb") - out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1) - out = out.gsub(__dir__, '') +ruby_version_is "3.0" do + describe "The --backtrace-limit command line option" do + it "limits top-level backtraces to a given number of entries" do + file = fixture(__FILE__ , "backtrace.rb") + out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1) + out = out.gsub(__dir__, '') - out.should == <<-MSG + out.should == <<-MSG top /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... - MSG - end + MSG + end - it "affects Exception#full_message" do - file = fixture(__FILE__ , "backtrace.rb") - out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1") - out = out.gsub(__dir__, '') + it "affects Exception#full_message" do + file = fixture(__FILE__ , "backtrace.rb") + out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1") + out = out.gsub(__dir__, '') - out.should == <<-MSG + out.should == <<-MSG full_message /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... - MSG - end + MSG + end - it "does not affect Exception#backtrace" do - file = fixture(__FILE__ , "backtrace.rb") - out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1") - out = out.gsub(__dir__, '') + it "does not affect Exception#backtrace" do + file = fixture(__FILE__ , "backtrace.rb") + out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1") + out = out.gsub(__dir__, '') - out.should == <<-MSG + out.should == <<-MSG backtrace /fixtures/backtrace.rb:2:in `a' /fixtures/backtrace.rb:6:in `b' /fixtures/backtrace.rb:10:in `c' /fixtures/backtrace.rb:14:in `d' /fixtures/backtrace.rb:29:in `<main>' - MSG + MSG + end end end diff --git a/spec/ruby/command_line/dash_upper_u_spec.rb b/spec/ruby/command_line/dash_upper_u_spec.rb index 15854e7b73..d62718b095 100644 --- a/spec/ruby/command_line/dash_upper_u_spec.rb +++ b/spec/ruby/command_line/dash_upper_u_spec.rb @@ -6,13 +6,6 @@ describe "ruby -U" do options: '-U').should == 'UTF-8' end - it "sets Encoding.default_internal to UTF-8 when RUBYOPT is empty or only spaces" do - ruby_exe('p Encoding.default_internal', - options: '-U', env: { 'RUBYOPT' => '' }).should == "#<Encoding:UTF-8>\n" - ruby_exe('p Encoding.default_internal', - options: '-U', env: { 'RUBYOPT' => ' ' }).should == "#<Encoding:UTF-8>\n" - end - it "does nothing different if specified multiple times" do ruby_exe('print Encoding.default_internal.name', options: '-U -U').should == 'UTF-8' diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb index 4019510d42..cbb040a8dd 100644 --- a/spec/ruby/command_line/dash_upper_w_spec.rb +++ b/spec/ruby/command_line/dash_upper_w_spec.rb @@ -19,26 +19,29 @@ describe "The -W command line option with 2" do it_behaves_like :command_line_verbose, "-W2" end -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" +# 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 -end -describe "The -W command line option with :no-deprecated" do - it "suppresses deprecation warnings" do - ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n" + describe "The -W command line option with :no-deprecated" do + it "suppresses deprecation warnings" do + ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n" + end end -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" + 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 -end -describe "The -W command line option with :no-experimental" do - it "suppresses experimental warnings" do - ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n" + describe "The -W command line option with :no-experimental" do + it "suppresses experimental warnings" do + ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n" + end end end diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb index 9b570fa1eb..a4f4dcd051 100644 --- a/spec/ruby/command_line/dash_v_spec.rb +++ b/spec/ruby/command_line/dash_v_spec.rb @@ -8,6 +8,6 @@ describe "The -v command line option" do it "prints version and ends" do ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION) end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) || - (defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?) + (defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?) end end diff --git a/spec/ruby/command_line/dash_w_spec.rb b/spec/ruby/command_line/dash_w_spec.rb index f310dca3ed..c262df12cc 100644 --- a/spec/ruby/command_line/dash_w_spec.rb +++ b/spec/ruby/command_line/dash_w_spec.rb @@ -4,7 +4,9 @@ require_relative 'shared/verbose' describe "The -w command line option" do it_behaves_like :command_line_verbose, "-w" - it "enables both deprecated and experimental warnings" do - ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n" + 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/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb index 4a24cc6795..1a9ea925c9 100644 --- a/spec/ruby/command_line/feature_spec.rb +++ b/spec/ruby/command_line/feature_spec.rb @@ -43,9 +43,7 @@ describe "The --enable and --disable flags" do ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false" end - # frequently hangs for >60s on GitHub Actions macos-latest - # MinGW's YJIT support seems broken - platform_is_not :darwin, :mingw do + platform_is_not :darwin do # frequently hangs for >60s on GitHub Actions macos-latest it "can be used with all for enable" do e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]" env = {'RUBYOPT' => '-w'} diff --git a/spec/ruby/command_line/fixtures/bin/embedded_ruby.txt b/spec/ruby/command_line/fixtures/bin/embedded_ruby.txt index 1da779b1b9..c556bf0b71 100644 --- a/spec/ruby/command_line/fixtures/bin/embedded_ruby.txt +++ b/spec/ruby/command_line/fixtures/bin/embedded_ruby.txt @@ -1,3 +1,3 @@ @@@This line is not value Ruby #!ruby -puts 'success' +puts 'success'
\ No newline at end of file diff --git a/spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rb b/spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rb Binary files differindex df4b952c46..fa348d59e7 100644 --- a/spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rb +++ b/spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rb diff --git a/spec/ruby/command_line/fixtures/freeze_flag_two_literals.rb b/spec/ruby/command_line/fixtures/freeze_flag_two_literals.rb index f5547a5bae..074092c9d9 100644 --- a/spec/ruby/command_line/fixtures/freeze_flag_two_literals.rb +++ b/spec/ruby/command_line/fixtures/freeze_flag_two_literals.rb @@ -1 +1 @@ -p "abc".equal?("abc") +p "abc".object_id == "abc".object_id diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb index bbea4d557d..a2b817bad8 100644 --- a/spec/ruby/command_line/rubyopt_spec.rb +++ b/spec/ruby/command_line/rubyopt_spec.rb @@ -59,22 +59,24 @@ describe "Processing RUBYOPT" do ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" end - it "suppresses deprecation warnings for '-W:no-deprecated'" do - ENV["RUBYOPT"] = '-W:no-deprecated' - result = ruby_exe('$; = ""', args: '2>&1') - result.should == "" - end + ruby_version_is "2.7" do + it "suppresses deprecation warnings for '-W:no-deprecated'" do + ENV["RUBYOPT"] = '-W:no-deprecated' + result = ruby_exe('$; = ""', args: '2>&1') + result.should == "" + end - it "suppresses experimental warnings for '-W:no-experimental'" do - ENV["RUBYOPT"] = '-W:no-experimental' - result = ruby_exe('case 0; in a; end', args: '2>&1') - result.should == "" - end + it "suppresses experimental warnings for '-W:no-experimental'" do + ENV["RUBYOPT"] = '-W:no-experimental' + result = ruby_exe('case 0; in a; end', args: '2>&1') + result.should == "" + end - it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do - ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental' - result = ruby_exe('case ($; = ""); in a; end', args: '2>&1') - result.should == "" + it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do + ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental' + result = ruby_exe('case ($; = ""); in a; end', args: '2>&1') + result.should == "" + end end it "requires the file for '-r'" do |
