From 55a4c972dffeab1589b44a9eeb69e8a17b87cd1d Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 13 Jan 2010 17:00:48 +0000 Subject: [PATCH] add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_process.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 3a7eb5068f..57ffdf958c 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -260,6 +260,24 @@ class TestProcess < Test::Unit::TestCase system({"fofo"=>"haha"}, *ENVCOMMAND, STDOUT=>"out") assert_match(/^fofo=haha$/, File.read("out").chomp) } + + old = ENV["hmm"] + begin + ENV["hmm"] = "fufu" + 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(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(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_unsetenv_others