aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-26 01:01:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-26 01:01:59 +0000
commit876d4c4cc8f704029116b901ec4f696082a6ee30 (patch)
treecfec6419d350dc431d27a3a88ac0d74deaf1298b /test
parentf4af54f212907bd2ecd0be9d1e9a6237641b24b3 (diff)
downloadruby-876d4c4cc8f704029116b901ec4f696082a6ee30.tar.gz
Revert r36213 "popen: shell commands with envvar"
* io.c (rb_io_s_popen): revert r36213 "popen: shell commands with envvar" because it disabled to let single command bypass shell. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_process.rb49
1 files changed, 15 insertions, 34 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index c7a88b1b49..d55496fb05 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -275,53 +275,34 @@ class TestProcess < Test::Unit::TestCase
assert_equal("PATH\n", io.read)
}
- with_tmpchdir {|d|
- system({"fofo"=>"haha"}, *ENVCOMMAND, STDOUT=>"out")
- assert_match(/^fofo=haha$/, File.read("out").chomp, message)
+ IO.popen([{"FOO"=>"BAR"}, *ENVCOMMAND]) {|io|
+ assert_match(/^FOO=BAR$/, io.read)
}
- end
- def _test_execopts_env_popen(cmd)
- message = cmd.inspect
- IO.popen([{"FOO"=>"BAR"}, *cmd]) {|io|
- assert_match(/^FOO=BAR$/, io.read, message)
+ with_tmpchdir {|d|
+ system({"fofo"=>"haha"}, *ENVCOMMAND, STDOUT=>"out")
+ assert_match(/^fofo=haha$/, File.read("out").chomp)
}
old = ENV["hmm"]
begin
ENV["hmm"] = "fufu"
- IO.popen(cmd) {|io| assert_match(/^hmm=fufu$/, io.read, message)}
- IO.popen([{"hmm"=>""}, *cmd]) {|io| assert_match(/^hmm=$/, io.read, message)}
- IO.popen([{"hmm"=>nil}, *cmd]) {|io| assert_not_match(/^hmm=/, io.read, message)}
+ IO.popen(ENVCOMMAND) {|io| assert_match(/^hmm=fufu$/, io.read) }
+ IO.popen([{"hmm"=>""}, *ENVCOMMAND]) {|io| assert_match(/^hmm=$/, io.read) }
+ IO.popen([{"hmm"=>nil}, *ENVCOMMAND]) {|io| assert_not_match(/^hmm=/, io.read) }
ENV["hmm"] = ""
- IO.popen(cmd) {|io| assert_match(/^hmm=$/, io.read, message)}
- IO.popen([{"hmm"=>""}, *cmd]) {|io| assert_match(/^hmm=$/, io.read, message)}
- IO.popen([{"hmm"=>nil}, *cmd]) {|io| assert_not_match(/^hmm=/, io.read, message)}
+ IO.popen(ENVCOMMAND) {|io| assert_match(/^hmm=$/, io.read) }
+ IO.popen([{"hmm"=>""}, *ENVCOMMAND]) {|io| assert_match(/^hmm=$/, io.read) }
+ IO.popen([{"hmm"=>nil}, *ENVCOMMAND]) {|io| assert_not_match(/^hmm=/, io.read) }
ENV["hmm"] = nil
- IO.popen(cmd) {|io| assert_not_match(/^hmm=/, io.read, message)}
- IO.popen([{"hmm"=>""}, *cmd]) {|io| assert_match(/^hmm=$/, io.read, message)}
- IO.popen([{"hmm"=>nil}, *cmd]) {|io| assert_not_match(/^hmm=/, io.read, message)}
+ IO.popen(ENVCOMMAND) {|io| assert_not_match(/^hmm=/, io.read) }
+ IO.popen([{"hmm"=>""}, *ENVCOMMAND]) {|io| assert_match(/^hmm=$/, io.read) }
+ IO.popen([{"hmm"=>nil}, *ENVCOMMAND]) {|io| assert_not_match(/^hmm=/, io.read) }
ensure
ENV["hmm"] = old
end
end
- def test_execopts_env_popen_vector
- _test_execopts_env_popen(ENVCOMMAND)
- end
-
- def test_execopts_env_popen_string
- with_tmpchdir do |d|
- open('test-script', 'w') do |f|
- ENVCOMMAND.each_with_index do |cmd, i|
- next if i.zero? or cmd == "-e"
- f.puts cmd
- end
- end
- _test_execopts_env_popen("#{RUBY} test-script")
- end
- end
-
def test_execopts_preserve_env_on_exec_failure
with_tmpchdir {|d|
write_file 's', <<-"End"
@@ -622,7 +603,7 @@ class TestProcess < Test::Unit::TestCase
def test_execopts_popen
with_tmpchdir {|d|
IO.popen("#{RUBY} -e 'puts :foo'") {|io| assert_equal("foo\n", io.read) }
- IO.popen(["echo bar"]) {|io| assert_equal("bar\n", io.read) }
+ assert_raise(Errno::ENOENT) { IO.popen(["echo bar"]) {} } # assuming "echo bar" command not exist.
IO.popen(ECHO["baz"]) {|io| assert_equal("baz\n", io.read) }
assert_raise(ArgumentError) {
IO.popen([*ECHO["qux"], STDOUT=>STDOUT]) {|io| }