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:
parent
126cf11d33
commit
3b86ec2251
1 changed files with 13 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue