summaryrefslogtreecommitdiff
path: root/spec/ruby/command_line
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-07-29 22:11:21 +0200
committerBenoit Daloze <eregontp@gmail.com>2021-07-29 22:11:21 +0200
commit6998d758248d778fa95b008c78d05473e48b8428 (patch)
tree8abc6926f647ea5f374a5b34c3a4820c5861e32e /spec/ruby/command_line
parent15d05f8120745a121b93fab9fd2addf5f094e8d2 (diff)
Update to ruby/spec@b65d01f
Diffstat (limited to 'spec/ruby/command_line')
-rw-r--r--spec/ruby/command_line/feature_spec.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb
index 16e106b37d5..1a9ea925c98 100644
--- a/spec/ruby/command_line/feature_spec.rb
+++ b/spec/ruby/command_line/feature_spec.rb
@@ -1,6 +1,12 @@
require_relative '../spec_helper'
describe "The --enable and --disable flags" do
+ before :all do
+ # Since some specs disable reading RUBYOPT, we instead pass its contents as :options for those specs
+ rubyopt = [ENV["RUBYOPT"]]
+ rubyopt << ENV["#{RUBY_ENGINE.upcase}OPT"] unless RUBY_ENGINE == 'ruby'
+ @rubyopt = RUBY_ENGINE == "ruby" ? "" : rubyopt.compact.join(" ")
+ end
it "can be used with gems" do
ruby_exe("p defined?(Gem)", options: "--enable=gems").chomp.should == "\"constant\""
@@ -25,9 +31,9 @@ describe "The --enable and --disable flags" do
it "can be used with rubyopt" do
ruby_exe("p $VERBOSE", options: "--enable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true"
- ruby_exe("p $VERBOSE", options: "--disable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
+ ruby_exe("p $VERBOSE", options: "#{@rubyopt} --disable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
ruby_exe("p $VERBOSE", options: "--enable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true"
- ruby_exe("p $VERBOSE", options: "--disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
+ ruby_exe("p $VERBOSE", options: "#{@rubyopt} --disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
end
it "can be used with frozen-string-literal" do
@@ -49,8 +55,8 @@ describe "The --enable and --disable flags" do
it "can be used with all for disable" do
e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
env = {'RUBYOPT' => '-w'}
- ruby_exe(e, options: "--disable=all", env: env).chomp.should == "[nil, nil, false, false]"
- ruby_exe(e, options: "--disable-all", env: env).chomp.should == "[nil, nil, false, false]"
+ ruby_exe(e, options: "#{@rubyopt} --disable=all", env: env).chomp.should == "[nil, nil, false, false]"
+ ruby_exe(e, options: "#{@rubyopt} --disable-all", env: env).chomp.should == "[nil, nil, false, false]"
end
it "prints a warning for unknown features" do