summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-04 16:21:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-04 16:21:38 +0000
commitd0553ffbb53c10ff5354d063c4c4d15348fe955e (patch)
treee1c807641da2aa3a30a7a2aba99bb9889df4face /test/ruby
parentee388f6ee2790908dffbb4b20d7d1d43b8ddb38a (diff)
* process.c (proc_exec_v, proc_spawn_v): try to execute with sh if
no shebang. [ruby-core:32745] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_process.rb14
-rw-r--r--test/ruby/test_system.rb11
2 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index df1086dad1..4e16400582 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1220,4 +1220,18 @@ class TestProcess < Test::Unit::TestCase
assert(status.success?, "[ruby-dev:38105]")
}
end
+
+ def test_fallback_to_sh
+ feature = '[ruby-core:32745]'
+ with_tmpchdir do |d|
+ open("tmp_script.#{$$}", "w") {|f| f.puts ": ;"; f.chmod(0755)}
+ assert_not_nil(pid = Process.spawn("./tmp_script.#{$$}"), feature)
+ wpid, st = Process.waitpid2(pid)
+ assert_equal([pid, true], [wpid, st.success?], feature)
+
+ open("tmp_script.#{$$}", "w") {|f| f.puts "echo $#: $@"; f.chmod(0755)}
+ result = IO.popen(["./tmp_script.#{$$}", "a b", "c"]) {|f| f.read}
+ assert_equal("2: a b c\n", result, feature)
+ end
+ end
end
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index 358fa54ef8..2a5107f70c 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -91,4 +91,15 @@ class TestSystem < Test::Unit::TestCase
def test_empty_evstr
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
end
+
+ def test_fallback_to_sh
+ Dir.mktmpdir("ruby_script_tmp") {|tmpdir|
+ tmpfilename = "#{tmpdir}/ruby_script_tmp.#{$$}"
+ open(tmpfilename, "w") {|f|
+ f.puts ": ;"
+ f.chmod(0755)
+ }
+ assert_equal(true, system(tmpfilename), '[ruby-core:32745]')
+ }
+ end
end