1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

dtrace: check for the command availablity with sudo

This commit is contained in:
Nobuyoshi Nakada 2019-06-30 18:41:17 +09:00
parent 126cf11d33
commit 3b86ec2251
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -52,7 +52,17 @@ else
warn "don't know how to check if built with #{impl} support" warn "don't know how to check if built with #{impl} support"
cmd = false cmd = false
end end
ok &= system(*cmd, err: IO::NULL, out: IO::NULL) if cmd
NEEDED_ENVS = [RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].compact
if cmd and ok
sudocmd = []
if sudo
sudocmd << sudo
NEEDED_ENVS.each {|name| val = ENV[name] and sudocmd << "#{name}=#{val}"}
end
ok = system(*sudocmd, *cmd, err: IO::NULL, out: IO::NULL)
end
module DTrace module DTrace
class TestCase < Test::Unit::TestCase class TestCase < Test::Unit::TestCase
@ -136,8 +146,8 @@ module DTrace
cmd = [*DTRACE_CMD, "-q", "-s", d_path, "-c", cmd ] cmd = [*DTRACE_CMD, "-q", "-s", d_path, "-c", cmd ]
end end
if sudo = @@sudo if sudo = @@sudo
[RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].each do |name| NEEDED_ENVS.each do |name|
if name and val = ENV[name] if val = ENV[name]
cmd.unshift("#{name}=#{val}") cmd.unshift("#{name}=#{val}")
end end
end end