(#20321) Be more descriptive in deprecation message
Facter::Util::Resoultion.exec can be used to run arbitrary commands. On
windows it is currently allowed to pass a shell builtin but we raise a
deprecation warning.
But the deprecation warning did not include the actual commandline it is
complaining about so if you have custom facts that make use of this
feature you may ask yourself why you see the message.
Add the actual command to the deprecation message so it easier to
resolve the issue.
Stefan Schulte authored 11 years ago
Adrien Thebo committed 11 years ago
168 | 168 |
|
169 | 169 |
begin
|
170 | 170 |
out = %x{#{code}}.chomp
|
171 | |
Facter.warnonce 'Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command' unless expanded_code
|
|
171 |
Facter.warnonce "Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass \"cmd /c your_builtin\" as a command (command responsible for this message was \"#{code}\")" unless expanded_code
|
172 | 172 |
rescue Errno::ENOENT => detail
|
173 | 173 |
# command not found on Windows
|
174 | 174 |
return nil
|
684 | 684 |
it "should try to run the command and return output of a shell-builtin" do
|
685 | 685 |
Facter::Util::Resolution.expects(:expand_command).with(%q{echo foo}).returns nil
|
686 | 686 |
Facter::Util::Resolution.expects(:`).with(%q{echo foo}).returns 'foo'
|
687 | |
Facter.expects(:warnonce).with('Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command')
|
|
687 |
Facter.expects(:warnonce).with 'Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command (command responsible for this message was "echo foo")'
|
688 | 688 |
Facter::Util::Resolution.exec(%q{echo foo}).should == 'foo'
|
689 | 689 |
end
|
690 | 690 |
it "should try to run the command and return nil if not shell-builtin" do
|