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_a_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_c_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_d_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_e_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_encoding_spec.rb30
-rw-r--r--spec/ruby/command_line/dash_external_encoding_spec.rb15
-rw-r--r--spec/ruby/command_line/dash_internal_encoding_spec.rb15
-rw-r--r--spec/ruby/command_line/dash_l_spec.rb31
-rw-r--r--spec/ruby/command_line/dash_n_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_p_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_r_spec.rb21
-rw-r--r--spec/ruby/command_line/dash_s_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_c_spec.rb20
-rw-r--r--spec/ruby/command_line/dash_upper_e_spec.rb29
-rw-r--r--spec/ruby/command_line/dash_upper_f_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_i_spec.rb42
-rw-r--r--spec/ruby/command_line/dash_upper_k_spec.rb76
-rw-r--r--spec/ruby/command_line/dash_upper_s_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_u_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_w_spec.rb36
-rw-r--r--spec/ruby/command_line/dash_upper_x_spec.rb6
-rw-r--r--spec/ruby/command_line/dash_v_spec.rb6
-rw-r--r--spec/ruby/command_line/dash_w_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_x_spec.rb4
-rw-r--r--spec/ruby/command_line/error_message_spec.rb6
-rw-r--r--spec/ruby/command_line/feature_spec.rb63
-rw-r--r--spec/ruby/command_line/fixtures/bin/hybrid_launcher.sh2
-rw-r--r--[-rwxr-xr-x]spec/ruby/command_line/fixtures/bin/launcher.rb0
-rw-r--r--spec/ruby/command_line/fixtures/dash_upper_c_script.rb (renamed from spec/ruby/command_line/fixtures/change_directory_script.rb)0
-rw-r--r--spec/ruby/command_line/fixtures/test_file.rb2
-rw-r--r--spec/ruby/command_line/frozen_strings_spec.rb41
-rw-r--r--spec/ruby/command_line/rubylib_spec.rb69
-rw-r--r--spec/ruby/command_line/rubyopt_spec.rb42
-rw-r--r--spec/ruby/command_line/shared/change_directory.rb21
-rw-r--r--spec/ruby/command_line/shared/verbose.rb2
-rw-r--r--spec/ruby/command_line/syntax_error_spec.rb2
36 files changed, 95 insertions, 512 deletions
diff --git a/spec/ruby/command_line/dash_a_spec.rb b/spec/ruby/command_line/dash_a_spec.rb
index 9ea135dc76..65f79ec208 100644
--- a/spec/ruby/command_line/dash_a_spec.rb
+++ b/spec/ruby/command_line/dash_a_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -a command line option" do
before :each do
@names = fixture __FILE__, "full_names.txt"
diff --git a/spec/ruby/command_line/dash_c_spec.rb b/spec/ruby/command_line/dash_c_spec.rb
index 6b3a5de685..375d945a07 100644
--- a/spec/ruby/command_line/dash_c_spec.rb
+++ b/spec/ruby/command_line/dash_c_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -c command line option" do
it "checks syntax in given file" do
diff --git a/spec/ruby/command_line/dash_d_spec.rb b/spec/ruby/command_line/dash_d_spec.rb
index 26891b4791..009a14e16c 100644
--- a/spec/ruby/command_line/dash_d_spec.rb
+++ b/spec/ruby/command_line/dash_d_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -d command line option" do
before :each do
diff --git a/spec/ruby/command_line/dash_e_spec.rb b/spec/ruby/command_line/dash_e_spec.rb
index 24ed34376d..3435e78e29 100644
--- a/spec/ruby/command_line/dash_e_spec.rb
+++ b/spec/ruby/command_line/dash_e_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -e command line option" do
it "evaluates the given string" do
@@ -23,7 +23,7 @@ describe "The -e command line option" do
#needs to test return => LocalJumpError
- describe "with -n and an Integer range" do
+ describe "with -n and a Fixnum range" do
before :each do
@script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
end
diff --git a/spec/ruby/command_line/dash_encoding_spec.rb b/spec/ruby/command_line/dash_encoding_spec.rb
deleted file mode 100644
index 36ce55af5f..0000000000
--- a/spec/ruby/command_line/dash_encoding_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The --encoding command line option" do
- before :each do
- @test_string = "print [Encoding.default_external.name, Encoding.default_internal&.name].inspect"
- @enc2 = Encoding::ISO_8859_1
- end
-
- describe "sets Encoding.default_external and optionally Encoding.default_internal" do
- it "if given a single encoding with an =" do
- ruby_exe(@test_string, options: "--disable-gems --encoding=big5").should == [Encoding::Big5.name, nil].inspect
- end
-
- it "if given a single encoding as a separate argument" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5").should == [Encoding::Big5.name, nil].inspect
- end
-
- it "if given two encodings with an =" do
- ruby_exe(@test_string, options: "--disable-gems --encoding=big5:#{@enc2}").should == [Encoding::Big5.name, @enc2.name].inspect
- end
-
- it "if given two encodings as a separate argument" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5:#{@enc2}").should == [Encoding::Big5.name, @enc2.name].inspect
- end
- end
-
- it "does not accept a third encoding" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5:#{@enc2}:utf-32le", args: "2>&1").should =~ /extra argument for --encoding: utf-32le/
- end
-end
diff --git a/spec/ruby/command_line/dash_external_encoding_spec.rb b/spec/ruby/command_line/dash_external_encoding_spec.rb
deleted file mode 100644
index f052674dc8..0000000000
--- a/spec/ruby/command_line/dash_external_encoding_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'The --external-encoding command line option sets Encoding.default_external' do
- before :each do
- @test_string = "print Encoding.default_external.name"
- end
-
- it "if given an encoding with an =" do
- ruby_exe(@test_string, options: '--external-encoding=big5').should == Encoding::Big5.name
- end
-
- it "if given an encoding as a separate argument" do
- ruby_exe(@test_string, options: '--external-encoding big5').should == Encoding::Big5.name
- end
-end
diff --git a/spec/ruby/command_line/dash_internal_encoding_spec.rb b/spec/ruby/command_line/dash_internal_encoding_spec.rb
deleted file mode 100644
index 3049040bb4..0000000000
--- a/spec/ruby/command_line/dash_internal_encoding_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'The --internal-encoding command line option sets Encoding.default_internal' do
- before :each do
- @test_string = "print Encoding.default_internal.name"
- end
-
- it "if given an encoding with an =" do
- ruby_exe(@test_string, options: '--internal-encoding=big5').should == Encoding::Big5.name
- end
-
- it "if given an encoding as a separate argument" do
- ruby_exe(@test_string, options: '--internal-encoding big5').should == Encoding::Big5.name
- end
-end
diff --git a/spec/ruby/command_line/dash_l_spec.rb b/spec/ruby/command_line/dash_l_spec.rb
deleted file mode 100644
index 5c1d3cf4cd..0000000000
--- a/spec/ruby/command_line/dash_l_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The -l command line option" do
- before :each do
- @names = fixture __FILE__, "full_names.txt"
- end
-
- it "chomps lines with default separator" do
- ruby_exe('puts $_.end_with?("\n")', options: "-n -l", escape: true,
- args: " < #{@names}").should ==
- "false\nfalse\nfalse\n"
- end
-
- it "chomps last line based on $/" do
- ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true,
- args: " < #{@names}").should ==
- "alice j\nbob field\njames grey\n"
- end
-
- it "sets $\\ to the value of $/" do
- ruby_exe("puts $\\ == $/", options: "-W0 -n -l", escape: true,
- args: " < #{@names}").should ==
- "true\ntrue\ntrue\n"
- end
-
- it "sets $-l" do
- ruby_exe("puts $-l", options: "-n -l", escape: true,
- args: " < #{@names}").should ==
- "true\ntrue\ntrue\n"
- end
-end
diff --git a/spec/ruby/command_line/dash_n_spec.rb b/spec/ruby/command_line/dash_n_spec.rb
index 9d331d6065..f4dd9f1851 100644
--- a/spec/ruby/command_line/dash_n_spec.rb
+++ b/spec/ruby/command_line/dash_n_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -n command line option" do
before :each do
@names = fixture __FILE__, "names.txt"
diff --git a/spec/ruby/command_line/dash_p_spec.rb b/spec/ruby/command_line/dash_p_spec.rb
index 39827c3868..67562b5bc3 100644
--- a/spec/ruby/command_line/dash_p_spec.rb
+++ b/spec/ruby/command_line/dash_p_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -p command line option" do
before :each do
@names = fixture __FILE__, "names.txt"
diff --git a/spec/ruby/command_line/dash_r_spec.rb b/spec/ruby/command_line/dash_r_spec.rb
index 46c000b9e7..3d3abcf0b7 100644
--- a/spec/ruby/command_line/dash_r_spec.rb
+++ b/spec/ruby/command_line/dash_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -r command line option" do
before :each do
@@ -7,22 +7,7 @@ describe "The -r command line option" do
end
it "requires the specified file" do
- out = ruby_exe(@script, options: "-r #{@test_file}")
- out.should include("REQUIRED")
- out.should include(@test_file + ".rb")
- end
-
- it "requires the file before parsing the main script" do
- out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1")
- $?.should_not.success?
- out.should include("REQUIRED")
- out.should include("syntax error")
- end
-
- it "does not require the file if the main script file does not exist" do
- out = `#{ruby_exe.to_a.join(' ')} -r #{@test_file} #{fixture(__FILE__, "does_not_exist.rb")} 2>&1`
- $?.should_not.success?
- out.should_not.include?("REQUIRED")
- out.should.include?("No such file or directory")
+ result = ruby_exe(@script, options: "-r #{@test_file}")
+ result.should include(@test_file + ".rb")
end
end
diff --git a/spec/ruby/command_line/dash_s_spec.rb b/spec/ruby/command_line/dash_s_spec.rb
index eaaeea7c96..70e41208e0 100644
--- a/spec/ruby/command_line/dash_s_spec.rb
+++ b/spec/ruby/command_line/dash_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -s command line option" do
describe "when using -- to stop parsing" do
diff --git a/spec/ruby/command_line/dash_upper_c_spec.rb b/spec/ruby/command_line/dash_upper_c_spec.rb
index ece1b32105..e8a54b01c1 100644
--- a/spec/ruby/command_line/dash_upper_c_spec.rb
+++ b/spec/ruby/command_line/dash_upper_c_spec.rb
@@ -1,6 +1,18 @@
-require_relative '../spec_helper'
-require_relative 'shared/change_directory'
+require File.expand_path('../../spec_helper', __FILE__)
-describe "The -C command line option" do
- it_behaves_like :command_line_change_directory, "-C"
+describe 'The -C command line option' do
+ before :all do
+ @script = fixture(__FILE__, 'dash_upper_c_script.rb')
+ @tempdir = File.dirname(@script)
+ end
+
+ it 'changes the PWD when using a file' do
+ output = ruby_exe(@script, options: "-C #{@tempdir}")
+ output.should == @tempdir
+ end
+
+ it 'changes the PWD when using -e' do
+ output = ruby_exe(nil, options: "-C #{@tempdir} -e 'print Dir.pwd'")
+ output.should == @tempdir
+ end
end
diff --git a/spec/ruby/command_line/dash_upper_e_spec.rb b/spec/ruby/command_line/dash_upper_e_spec.rb
index b3c6ce262b..716f1304b7 100644
--- a/spec/ruby/command_line/dash_upper_e_spec.rb
+++ b/spec/ruby/command_line/dash_upper_e_spec.rb
@@ -1,33 +1,4 @@
-require_relative '../spec_helper'
-
describe "ruby -E" do
- it "sets the external encoding with '-E external'" do
- result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
- result.should == "EUC-JP"
- end
-
- platform_is_not :windows do
- it "also sets the filesystem encoding with '-E external'" do
- result = ruby_exe("print Encoding.find('filesystem')", options: '-E euc-jp')
- result.should == "EUC-JP"
- end
- end
-
- it "sets the external encoding with '-E external:'" do
- result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
- result.should == "Shift_JIS"
- end
-
- it "sets the internal encoding with '-E :internal'" do
- ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
- should == 'Shift_JIS'
- end
-
- it "sets the external and internal encodings with '-E external:internal'" do
- ruby_exe("puts Encoding.default_external, Encoding.default_internal", options: '-E euc-jp:SHIFT_JIS').
- should == "EUC-JP\nShift_JIS\n"
- end
-
it "raises a RuntimeError if used with -U" do
ruby_exe("p 1",
options: '-Eascii:ascii -U',
diff --git a/spec/ruby/command_line/dash_upper_f_spec.rb b/spec/ruby/command_line/dash_upper_f_spec.rb
index 967acc2ece..020968b1f9 100644
--- a/spec/ruby/command_line/dash_upper_f_spec.rb
+++ b/spec/ruby/command_line/dash_upper_f_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "the -F command line option" do
before :each do
@passwd = fixture __FILE__, "passwd_file.txt"
diff --git a/spec/ruby/command_line/dash_upper_i_spec.rb b/spec/ruby/command_line/dash_upper_i_spec.rb
index 4cafb724e3..0a00059949 100644
--- a/spec/ruby/command_line/dash_upper_i_spec.rb
+++ b/spec/ruby/command_line/dash_upper_i_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -I command line option" do
before :each do
@@ -8,44 +8,4 @@ describe "The -I command line option" do
it "adds the path to the load path ($:)" do
ruby_exe(@script, options: "-I fixtures").should include("fixtures")
end
-
- it "adds the path at the front of $LOAD_PATH" do
- lines = ruby_exe(@script, options: "-I fixtures").lines
- if PlatformGuard.implementation? :ruby
- # In a MRI checkout, $PWD ends up as the first entry in $LOAD_PATH.
- # So just assert that it's at the beginning.
- idx = lines.index { |l| l.include?("fixtures") }
- idx.should < 2
- idx.should < lines.size-1
- else
- lines[0].should include("fixtures")
- end
- end
-
- it "adds the path expanded from CWD to $LOAD_PATH" do
- ruby_exe(@script, options: "-I fixtures").lines.should include "#{Dir.pwd}/fixtures\n"
- end
-
- it "expands a path from CWD even if it does not exist" do
- ruby_exe(@script, options: "-I not_exist/not_exist").lines.should include "#{Dir.pwd}/not_exist/not_exist\n"
- end
-end
-
-platform_is_not :windows do
- describe "The -I command line option" do
- before :each do
- @script = fixture __FILE__, "loadpath.rb"
- @fixtures = File.dirname(@script)
- @symlink = tmp("loadpath_symlink")
- File.symlink(@fixtures, @symlink)
- end
-
- after :each do
- rm_r @symlink
- end
-
- it "does not expand symlinks" do
- ruby_exe(@script, options: "-I #{@symlink}").lines.should include "#{@symlink}\n"
- end
- end
end
diff --git a/spec/ruby/command_line/dash_upper_k_spec.rb b/spec/ruby/command_line/dash_upper_k_spec.rb
index 7e71532295..3c3b9fa4d3 100644
--- a/spec/ruby/command_line/dash_upper_k_spec.rb
+++ b/spec/ruby/command_line/dash_upper_k_spec.rb
@@ -1,65 +1,33 @@
-require_relative '../spec_helper'
-
-describe 'The -K command line option' do
- before :each do
- @test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
+describe 'The -K command line option sets __ENCODING__' do
+ it "to Encoding::ASCII_8BIT with -Ka" do
+ ruby_exe("print __ENCODING__", options: '-Ka').should == Encoding::ASCII_8BIT.to_s
end
- describe 'sets __ENCODING__ and Encoding.default_external' do
- it "to Encoding::BINARY with -Ka" do
- ruby_exe(@test_string, options: '-Ka').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -KA" do
- ruby_exe(@test_string, options: '-KA').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -Kn" do
- ruby_exe(@test_string, options: '-Kn').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -KN" do
- ruby_exe(@test_string, options: '-KN').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::EUC_JP with -Ke" do
- ruby_exe(@test_string, options: '-Ke').should ==
- [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
- end
+ it "to Encoding::ASCII_8BIT with -KA" do
+ ruby_exe("print __ENCODING__", options: '-KA').should == Encoding::ASCII_8BIT.to_s
+ end
- it "to Encoding::EUC_JP with -KE" do
- ruby_exe(@test_string, options: '-KE').should ==
- [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
- end
+ it "to Encoding::EUC_JP with -Ke" do
+ ruby_exe("print __ENCODING__", options: '-Ke').should == Encoding::EUC_JP.to_s
+ end
- it "to Encoding::UTF_8 with -Ku" do
- ruby_exe(@test_string, options: '-Ku').should ==
- [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
- end
+ it "to Encoding::EUC_JP with -KE" do
+ ruby_exe("print __ENCODING__", options: '-KE').should == Encoding::EUC_JP.to_s
+ end
- it "to Encoding::UTF_8 with -KU" do
- ruby_exe(@test_string, options: '-KU').should ==
- [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
- end
+ it "to Encoding::UTF_8 with -Ku" do
+ ruby_exe("print __ENCODING__", options: '-Ku').should == Encoding::UTF_8.to_s
+ end
- it "to Encoding::Windows_31J with -Ks" do
- ruby_exe(@test_string, options: '-Ks').should ==
- [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
- end
+ it "to Encoding::UTF_8 with -KU" do
+ ruby_exe("print __ENCODING__", options: '-KU').should == Encoding::UTF_8.to_s
+ end
- it "to Encoding::Windows_31J with -KS" do
- ruby_exe(@test_string, options: '-KS').should ==
- [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
- end
+ it "to Encoding::Windows_31J with -Ks" do
+ ruby_exe("print __ENCODING__", options: '-Ks').should == Encoding::Windows_31J.to_s
end
- it "ignores unknown codes" do
- external = Encoding.find('external')
- ruby_exe(@test_string, options: '-KZ').should ==
- [Encoding::UTF_8.name, external.name, nil].inspect
+ it "to Encoding::Windows_31J with -KS" do
+ ruby_exe("print __ENCODING__", options: '-KS').should == Encoding::Windows_31J.to_s
end
end
diff --git a/spec/ruby/command_line/dash_upper_s_spec.rb b/spec/ruby/command_line/dash_upper_s_spec.rb
index 3a28fa2ad2..2e293e9a62 100644
--- a/spec/ruby/command_line/dash_upper_s_spec.rb
+++ b/spec/ruby/command_line/dash_upper_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe 'The -S command line option' do
before :each do
diff --git a/spec/ruby/command_line/dash_upper_u_spec.rb b/spec/ruby/command_line/dash_upper_u_spec.rb
index 2546b5b9f4..6cd52a3647 100644
--- a/spec/ruby/command_line/dash_upper_u_spec.rb
+++ b/spec/ruby/command_line/dash_upper_u_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "ruby -U" do
it "sets Encoding.default_internal to UTF-8" do
ruby_exe('print Encoding.default_internal.name',
diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb
index b705638606..4e517a422a 100644
--- a/spec/ruby/command_line/dash_upper_w_spec.rb
+++ b/spec/ruby/command_line/dash_upper_w_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -W command line option" do
before :each do
@@ -18,35 +18,3 @@ 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
- before do
- ruby_version_is ""..."3.0" do
- @src = 'case [0, 1]; in [a, b]; end'
- end
-
- ruby_version_is "3.0" do
- @src = '[0, 1] => [a, b]'
- end
- end
-
- 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 == ""
- end
- end
-end
diff --git a/spec/ruby/command_line/dash_upper_x_spec.rb b/spec/ruby/command_line/dash_upper_x_spec.rb
deleted file mode 100644
index 8ef9aae4b1..0000000000
--- a/spec/ruby/command_line/dash_upper_x_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../spec_helper'
-require_relative 'shared/change_directory'
-
-describe "The -X command line option" do
- it_behaves_like :command_line_change_directory, "-X"
-end
diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb
index 04d684fdad..2ee9099419 100644
--- a/spec/ruby/command_line/dash_v_spec.rb
+++ b/spec/ruby/command_line/dash_v_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -v command line option" do
it_behaves_like :command_line_verbose, "-v"
describe "when used alone" do
it "prints version and ends" do
- ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
+ ruby_exe(nil, args: '-v').include?(RUBY_DESCRIPTION).should == true
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..bb038cb10c 100644
--- a/spec/ruby/command_line/dash_w_spec.rb
+++ b/spec/ruby/command_line/dash_w_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -w command line option" do
it_behaves_like :command_line_verbose, "-w"
diff --git a/spec/ruby/command_line/dash_x_spec.rb b/spec/ruby/command_line/dash_x_spec.rb
index eb89db0144..a5306b4f75 100644
--- a/spec/ruby/command_line/dash_x_spec.rb
+++ b/spec/ruby/command_line/dash_x_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -x command line option" do
it "runs code after the first /\#!.*ruby.*/-ish line in target file" do
embedded_ruby = fixture __FILE__, "bin/embedded_ruby.txt"
@@ -18,4 +16,6 @@ describe "The -x command line option" do
result = ruby_exe(embedded_ruby)
result.should == "success\n"
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/command_line/error_message_spec.rb b/spec/ruby/command_line/error_message_spec.rb
index f3f7de4fd4..6212452739 100644
--- a/spec/ruby/command_line/error_message_spec.rb
+++ b/spec/ruby/command_line/error_message_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The error message caused by an exception" do
it "is not printed to stdout" do
out = ruby_exe("this_does_not_exist", args: "2> #{File::NULL}")
- out.chomp.should.empty?
+ out.chomp.empty?.should == true
out = ruby_exe("end #syntax error", args: "2> #{File::NULL}")
- out.chomp.should.empty?
+ out.chomp.empty?.should == true
end
end
diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb
deleted file mode 100644
index 16e106b37d..0000000000
--- a/spec/ruby/command_line/feature_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The --enable and --disable flags" do
-
- it "can be used with gems" do
- ruby_exe("p defined?(Gem)", options: "--enable=gems").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable=gems").chomp.should == "nil"
- ruby_exe("p defined?(Gem)", options: "--enable-gems").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable-gems").chomp.should == "nil"
- end
-
- it "can be used with gem" do
- ruby_exe("p defined?(Gem)", options: "--enable=gem").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable=gem").chomp.should == "nil"
- ruby_exe("p defined?(Gem)", options: "--enable-gem").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable-gem").chomp.should == "nil"
- end
-
- it "can be used with did_you_mean" do
- ruby_exe("p defined?(DidYouMean)", options: "--enable=did_you_mean").chomp.should == "\"constant\""
- ruby_exe("p defined?(DidYouMean)", options: "--disable=did_you_mean").chomp.should == "nil"
- ruby_exe("p defined?(DidYouMean)", options: "--enable-did_you_mean").chomp.should == "\"constant\""
- ruby_exe("p defined?(DidYouMean)", options: "--disable-did_you_mean").chomp.should == "nil"
- end
-
- 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: "--enable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true"
- ruby_exe("p $VERBOSE", options: "--disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
- end
-
- it "can be used with frozen-string-literal" do
- ruby_exe("p 'foo'.frozen?", options: "--enable=frozen-string-literal").chomp.should == "true"
- ruby_exe("p 'foo'.frozen?", options: "--disable=frozen-string-literal").chomp.should == "false"
- ruby_exe("p 'foo'.frozen?", options: "--enable-frozen-string-literal").chomp.should == "true"
- ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
- end
-
- 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
- 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]"
- end
-
- it "prints a warning for unknown features" do
- ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
- ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
- ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
- ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
- end
-
-end
diff --git a/spec/ruby/command_line/fixtures/bin/hybrid_launcher.sh b/spec/ruby/command_line/fixtures/bin/hybrid_launcher.sh
index fd3249f0e5..0eede2a99f 100644
--- a/spec/ruby/command_line/fixtures/bin/hybrid_launcher.sh
+++ b/spec/ruby/command_line/fixtures/bin/hybrid_launcher.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
-echo 'error' && exit 1
+exec somehow this file
#!ruby
puts 'success'
diff --git a/spec/ruby/command_line/fixtures/bin/launcher.rb b/spec/ruby/command_line/fixtures/bin/launcher.rb
index 92a0ee2b49..92a0ee2b49 100755..100644
--- a/spec/ruby/command_line/fixtures/bin/launcher.rb
+++ b/spec/ruby/command_line/fixtures/bin/launcher.rb
diff --git a/spec/ruby/command_line/fixtures/change_directory_script.rb b/spec/ruby/command_line/fixtures/dash_upper_c_script.rb
index abe244705f..abe244705f 100644
--- a/spec/ruby/command_line/fixtures/change_directory_script.rb
+++ b/spec/ruby/command_line/fixtures/dash_upper_c_script.rb
diff --git a/spec/ruby/command_line/fixtures/test_file.rb b/spec/ruby/command_line/fixtures/test_file.rb
index 30a832299e..961e3c0b0c 100644
--- a/spec/ruby/command_line/fixtures/test_file.rb
+++ b/spec/ruby/command_line/fixtures/test_file.rb
@@ -1 +1 @@
-puts "REQUIRED"
+"test file"
diff --git a/spec/ruby/command_line/frozen_strings_spec.rb b/spec/ruby/command_line/frozen_strings_spec.rb
index 647b69daed..f3ee797c78 100644
--- a/spec/ruby/command_line/frozen_strings_spec.rb
+++ b/spec/ruby/command_line/frozen_strings_spec.rb
@@ -1,29 +1,30 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
-describe "The --enable-frozen-string-literal flag causes string literals to" do
+ruby_version_is "2.3" do
+ describe "The --enable-frozen-string-literal flag causes string literals to" do
- it "produce the same object each time" do
- ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object each time" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce the same object for literals with the same content" do
- ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object for literals with the same content" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce the same object for literals with the same content in different files" do
- ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object for literals with the same content in different files" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce different objects for literals with the same content in different files if they have different encodings" do
- ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ it "produce different objects for literals with the same content in different files if they have different encodings" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
end
-end
-describe "The --debug flag produces" do
- it "debugging info on attempted frozen string modification" do
- error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--debug', args: "2>&1")
- error_str.should include("can't modify frozen String")
- error_str.should include("created at")
- error_str.should include("command_line/fixtures/debug_info.rb:2")
+ describe "The --debug flag produces" do
+ it "debugging info on attempted frozen string modification" do
+ error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--debug', args: "2>&1")
+ error_str.should include("can't modify frozen String, created at ")
+ error_str.should include("command_line/fixtures/debug_info.rb:2")
+ end
end
end
diff --git a/spec/ruby/command_line/rubylib_spec.rb b/spec/ruby/command_line/rubylib_spec.rb
deleted file mode 100644
index b45919b997..0000000000
--- a/spec/ruby/command_line/rubylib_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The RUBYLIB environment variable" do
- before :each do
- @rubylib, ENV["RUBYLIB"] = ENV["RUBYLIB"], nil
- @pre = @rubylib.nil? ? '' : @rubylib + File::PATH_SEPARATOR
- end
-
- after :each do
- ENV["RUBYLIB"] = @rubylib
- end
-
- it "adds a directory to $LOAD_PATH" do
- dir = tmp("rubylib/incl")
- ENV["RUBYLIB"] = @pre + dir
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.should include(dir)
- end
-
- it "adds a File::PATH_SEPARATOR-separated list of directories to $LOAD_PATH" do
- dir1, dir2 = tmp("rubylib/incl1"), tmp("rubylib/incl2")
- ENV["RUBYLIB"] = @pre + "#{dir1}#{File::PATH_SEPARATOR}#{dir2}"
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.should include(dir1)
- paths.should include(dir2)
- paths.index(dir1).should < paths.index(dir2)
- end
-
- it "adds the directory at the front of $LOAD_PATH" do
- dir = tmp("rubylib/incl_front")
- ENV["RUBYLIB"] = @pre + dir
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.shift if paths.first.end_with?('/gem-rehash')
- if PlatformGuard.implementation? :ruby
- # In a MRI checkout, $PWD and some extra -I entries end up as
- # the first entries in $LOAD_PATH. So just assert that it's not last.
- idx = paths.index(dir)
- idx.should < paths.size-1
- else
- paths[0].should == dir
- end
- end
-
- it "adds the directory after directories added by -I" do
- dash_i_dir = tmp("dash_I_include")
- rubylib_dir = tmp("rubylib_include")
- ENV["RUBYLIB"] = @pre + rubylib_dir
- paths = ruby_exe("puts $LOAD_PATH", options: "-I #{dash_i_dir}").lines.map(&:chomp)
- paths.should include(dash_i_dir)
- paths.should include(rubylib_dir)
- paths.index(dash_i_dir).should < paths.index(rubylib_dir)
- end
-
- it "adds the directory after directories added by -I within RUBYOPT" do
- rubyopt_dir = tmp("rubyopt_include")
- rubylib_dir = tmp("rubylib_include")
- ENV["RUBYLIB"] = @pre + rubylib_dir
- paths = ruby_exe("puts $LOAD_PATH", env: { "RUBYOPT" => "-I#{rubyopt_dir}" }).lines.map(&:chomp)
- paths.should include(rubyopt_dir)
- paths.should include(rubylib_dir)
- paths.index(rubyopt_dir).should < paths.index(rubylib_dir)
- end
-
- it "keeps spaces in the value" do
- ENV["RUBYLIB"] = @pre + " rubylib/incl "
- out = ruby_exe("puts $LOAD_PATH")
- out.should include(" rubylib/incl ")
- end
-end
diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb
index a739f23eb8..a662b026bf 100644
--- a/spec/ruby/command_line/rubyopt_spec.rb
+++ b/spec/ruby/command_line/rubyopt_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Processing RUBYOPT" do
- before :each do
+ before (:each) do
@rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], nil
end
- after :each do
+ after (:each) do
ENV["RUBYOPT"] = @rubyopt
end
@@ -22,16 +22,14 @@ describe "Processing RUBYOPT" do
result.should =~ /value of \$DEBUG is true/
end
- guard -> { not CROSS_COMPILING } do
- it "prints the version number for '-v'" do
- ENV["RUBYOPT"] = '-v'
- ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
- end
+ it "prints the version number for '-v'" do
+ ENV["RUBYOPT"] = '-v'
+ ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
+ end
- it "ignores whitespace around the option" do
- ENV["RUBYOPT"] = ' -v '
- ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
- end
+ it "ignores whitespace around the option" do
+ ENV["RUBYOPT"] = ' -v '
+ ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
end
it "sets $VERBOSE to true for '-w'" do
@@ -59,26 +57,6 @@ 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('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 == ""
- end
- end
-
it "requires the file for '-r'" do
f = fixture __FILE__, "rubyopt"
ENV["RUBYOPT"] = "-r#{f}"
diff --git a/spec/ruby/command_line/shared/change_directory.rb b/spec/ruby/command_line/shared/change_directory.rb
deleted file mode 100644
index 9cb6e90ac6..0000000000
--- a/spec/ruby/command_line/shared/change_directory.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-describe :command_line_change_directory, shared: true do
- before :all do
- @script = fixture(__FILE__, 'change_directory_script.rb')
- @tempdir = File.dirname(@script)
- end
-
- it 'changes the PWD when using a file' do
- output = ruby_exe(@script, options: "#{@method} #{@tempdir}")
- output.should == @tempdir
- end
-
- it 'does not need a space after -C for the argument' do
- output = ruby_exe(@script, options: "#{@method}#{@tempdir}")
- output.should == @tempdir
- end
-
- it 'changes the PWD when using -e' do
- output = ruby_exe(nil, options: "#{@method} #{@tempdir} -e 'print Dir.pwd'")
- output.should == @tempdir
- end
-end
diff --git a/spec/ruby/command_line/shared/verbose.rb b/spec/ruby/command_line/shared/verbose.rb
index c5c44c269e..457fe3006a 100644
--- a/spec/ruby/command_line/shared/verbose.rb
+++ b/spec/ruby/command_line/shared/verbose.rb
@@ -4,6 +4,6 @@ describe :command_line_verbose, shared: true do
end
it "sets $VERBOSE to true" do
- ruby_exe(@script, options: @method).chomp.b.split.last.should == "true"
+ ruby_exe(@script, options: @method).chomp.split.last.should == "true"
end
end
diff --git a/spec/ruby/command_line/syntax_error_spec.rb b/spec/ruby/command_line/syntax_error_spec.rb
index f61cfe928d..71cee32e23 100644
--- a/spec/ruby/command_line/syntax_error_spec.rb
+++ b/spec/ruby/command_line/syntax_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The interpreter" do
it "prints an error when given a file with invalid syntax" do