|
2 | 2 |
|
3 | 3 | describe 'The -S command line option' do |
4 | 4 | before :each do |
5 | | - @path = [ENV['PATH'], fixture(__FILE__, "bin")].join(':') |
| 5 | + @bin = fixture(__FILE__, "bin") |
| 6 | + @path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR) |
6 | 7 | end |
7 | 8 |
|
8 | 9 | platform_is_not :windows do |
9 | 10 | # On VirtualBox shared directory (vboxsf) all files are world writable |
10 | 11 | # and MRI shows warning when including world writable path in ENV['PATH']. |
11 | 12 | # This is why we are using /success$/ matching in the following cases. |
12 | 13 |
|
| 14 | + it "runs launcher found in RUBYPATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do |
| 15 | + result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'RUBYPATH' => @bin }, args: '2>&1') |
| 16 | + result.should =~ /success$/ |
| 17 | + end |
| 18 | + |
13 | 19 | it "runs launcher found in PATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do |
14 | 20 | result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'PATH' => @path }, args: '2>&1') |
15 | 21 | result.should =~ /success$/ |
16 | 22 | end |
17 | 23 |
|
| 24 | + it "runs launcher found in RUBYPATH" do |
| 25 | + result = ruby_exe(nil, options: '-S launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1') |
| 26 | + result.should =~ /success$/ |
| 27 | + end |
| 28 | + |
18 | 29 | it "runs launcher found in PATH" do |
19 | 30 | result = ruby_exe(nil, options: '-S launcher.rb', env: { 'PATH' => @path }, args: '2>&1') |
20 | 31 | result.should =~ /success$/ |
21 | 32 | end |
22 | 33 |
|
| 34 | + it "runs launcher found in RUBYPATH and sets the exit status to 1 if it fails" do |
| 35 | + result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1) |
| 36 | + result.should =~ /\bdie\b/ |
| 37 | + $?.exitstatus.should == 1 |
| 38 | + end |
| 39 | + |
23 | 40 | it "runs launcher found in PATH and sets the exit status to 1 if it fails" do |
24 | 41 | result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1) |
25 | 42 | result.should =~ /\bdie\b/ |
26 | 43 | $?.exitstatus.should == 1 |
27 | 44 | end |
| 45 | + |
| 46 | + ruby_version_is "4.1" do |
| 47 | + describe "if the script name contains separator" do |
| 48 | + before(:each) do |
| 49 | + @bin = File.dirname(@bin) |
| 50 | + @path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR) |
| 51 | + end |
| 52 | + |
| 53 | + it "does not search launcher in RUBYPATH" do |
| 54 | + result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1) |
| 55 | + result.should =~ /LoadError/ |
| 56 | + $?.should_not.success? |
| 57 | + end |
| 58 | + |
| 59 | + it "does not search launcher in PATH" do |
| 60 | + result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1) |
| 61 | + result.should =~ /LoadError/ |
| 62 | + $?.should_not.success? |
| 63 | + end |
| 64 | + end |
| 65 | + end |
28 | 66 | end |
29 | 67 | end |
0 commit comments