summaryrefslogtreecommitdiff
path: root/spec/ruby/command_line
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/command_line')
-rw-r--r--spec/ruby/command_line/dash_upper_w_spec.rb22
-rw-r--r--spec/ruby/command_line/feature_spec.rb12
-rw-r--r--spec/ruby/command_line/rubyopt_spec.rb20
3 files changed, 49 insertions, 5 deletions
diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb
index 31bb976ad2..8343bc08e4 100644
--- a/spec/ruby/command_line/dash_upper_w_spec.rb
+++ b/spec/ruby/command_line/dash_upper_w_spec.rb
@@ -18,3 +18,25 @@ end
describe "The -W command line option with 2" do
it_behaves_like :command_line_verbose, "-W2"
end
+
+ruby_version_is "2.7" do
+ 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 == ""
+ end
+ end
+
+ describe "The -W command line option with :no-experimental" do
+ it "suppresses experimental warnings" do
+ result = ruby_exe('0 in a', args: '2>&1')
+ result.should =~ /is experimental/
+
+ result = ruby_exe('0 in a', options: '-W:no-experimental', args: '2>&1')
+ result.should == ""
+ end
+ end
+end
diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb
index 8848249c64..16e106b37d 100644
--- a/spec/ruby/command_line/feature_spec.rb
+++ b/spec/ruby/command_line/feature_spec.rb
@@ -37,11 +37,13 @@ describe "The --enable and --disable flags" do
ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
end
- it "can be used with all for enable" do
- e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
- env = {'RUBYOPT' => '-w'}
- # Use a single variant here because it can be quite slow as it might enable jit, etc
- ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
+ 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'}
+ # Use a single variant here because it can be quite slow as it might enable jit, etc
+ ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
+ end
end
it "can be used with all for disable" do
diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb
index 2db42f77ef..ee4e594a1c 100644
--- a/spec/ruby/command_line/rubyopt_spec.rb
+++ b/spec/ruby/command_line/rubyopt_spec.rb
@@ -59,6 +59,26 @@ describe "Processing RUBYOPT" do
ruby_exe("p $VERBOSE", escape: true).chomp.should == "true"
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('0 in a', 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('($; = "") in a', args: '2>&1')
+ result.should == ""
+ end
+ end
+
it "requires the file for '-r'" do
f = fixture __FILE__, "rubyopt"
ENV["RUBYOPT"] = "-r#{f}"