mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 02:53:57 +02:00
* test/ruby/test_process.rb (TestProcess::MANDATORY_ENVS): some
platforms need environments for shared objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
07f0d97d87
commit
a931f96111
2 changed files with 32 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Jan 9 10:40:52 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/ruby/test_process.rb (TestProcess::MANDATORY_ENVS): some
|
||||||
|
platforms need environments for shared objects.
|
||||||
|
|
||||||
Thu Jan 8 23:19:38 2009 Tanaka Akira <akr@fsij.org>
|
Thu Jan 8 23:19:38 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/socket.c (bsock_shutdown): accept symbol/string as how.
|
* ext/socket/socket.c (bsock_shutdown): accept symbol/string as how.
|
||||||
|
|
|
@ -2,6 +2,7 @@ require 'test/unit'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require_relative 'envutil'
|
require_relative 'envutil'
|
||||||
|
require 'rbconfig'
|
||||||
|
|
||||||
class TestProcess < Test::Unit::TestCase
|
class TestProcess < Test::Unit::TestCase
|
||||||
RUBY = EnvUtil.rubybin
|
RUBY = EnvUtil.rubybin
|
||||||
|
@ -198,7 +199,16 @@ class TestProcess < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
ENVCOMMAND = [RUBY, '-e', 'ENV.each {|k,v| puts "#{k}=#{v}" }']
|
MANDATORY_ENVS = []
|
||||||
|
if /linux/ =~ RbConfig::CONFIG['target_os']
|
||||||
|
MANDATORY_ENVS << 'LD_PRELOAD'
|
||||||
|
end
|
||||||
|
if e = RbConfig::CONFIG['LIBPATHENV']
|
||||||
|
MANDATORY_ENVS << e
|
||||||
|
end
|
||||||
|
PREENVARG = ['-e', "%w[#{MANDATORY_ENVS.join(' ')}].each{|e|ENV.delete(e)}"]
|
||||||
|
ENVARG = ['-e', 'ENV.each {|k,v| puts "#{k}=#{v}" }']
|
||||||
|
ENVCOMMAND = [RUBY].concat(PREENVARG).concat(ENVARG)
|
||||||
|
|
||||||
def test_execopts_env
|
def test_execopts_env
|
||||||
assert_raise(ArgumentError) {
|
assert_raise(ArgumentError) {
|
||||||
|
@ -206,8 +216,18 @@ class TestProcess < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
h = {}
|
h = {}
|
||||||
ENV.each {|k,v| h[k] = nil unless k.upcase == "PATH" }
|
cmd = [h, RUBY]
|
||||||
IO.popen([h, RUBY, '-e', 'puts ENV.keys.map{|e|e.upcase}']) {|io|
|
ENV.each do |k,v|
|
||||||
|
case k
|
||||||
|
when /\APATH\z/i
|
||||||
|
when *MANDATORY_ENVS
|
||||||
|
cmd << '-e' << "ENV.delete('#{k}')"
|
||||||
|
else
|
||||||
|
h[k] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cmd << '-e' << 'puts ENV.keys.map{|e|e.upcase}'
|
||||||
|
IO.popen(cmd) {|io|
|
||||||
assert_equal("PATH\n", io.read)
|
assert_equal("PATH\n", io.read)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,10 +242,12 @@ class TestProcess < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execopts_unsetenv_others
|
def test_execopts_unsetenv_others
|
||||||
IO.popen([*ENVCOMMAND, :unsetenv_others=>true]) {|io|
|
h = {}
|
||||||
|
MANDATORY_ENVS.each {|k| e = ENV[k] and h[k] = e}
|
||||||
|
IO.popen([h, *ENVCOMMAND, :unsetenv_others=>true]) {|io|
|
||||||
assert_equal("", io.read)
|
assert_equal("", io.read)
|
||||||
}
|
}
|
||||||
IO.popen([{"A"=>"B"}, *ENVCOMMAND, :unsetenv_others=>true]) {|io|
|
IO.popen([h.merge("A"=>"B"), *ENVCOMMAND, :unsetenv_others=>true]) {|io|
|
||||||
assert_equal("A=B\n", io.read)
|
assert_equal("A=B\n", io.read)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue