Codebase list facter / e5b8cd5
(#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
2 changed file(s) with 2 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
168168
169169 begin
170170 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
172172 rescue Errno::ENOENT => detail
173173 # command not found on Windows
174174 return nil
684684 it "should try to run the command and return output of a shell-builtin" do
685685 Facter::Util::Resolution.expects(:expand_command).with(%q{echo foo}).returns nil
686686 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")'
688688 Facter::Util::Resolution.exec(%q{echo foo}).should == 'foo'
689689 end
690690 it "should try to run the command and return nil if not shell-builtin" do