aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_process.rb18
1 files changed, 18 insertions, 0 deletions
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