diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-03-01 15:04:35 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2016-03-01 16:27:14 -0800 |
commit | 0a626034cfe572c94606b2ebae1aae29201620cf (patch) | |
tree | 5dbec956da3cf936ec8d761c7a8ede0175c1e41b | |
parent | ba81b5ce825477fcb8b4e9684337c7f666b0f6e3 (diff) | |
download | ohai-0a626034cfe572c94606b2ebae1aae29201620cf.tar.gz |
Add debug output to the which helper
-rw-r--r-- | lib/ohai/util/file_helper.rb | 6 | ||||
-rw-r--r-- | spec/unit/util/file_helper_spec.rb | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/ohai/util/file_helper.rb b/lib/ohai/util/file_helper.rb index 1f78d5a6..5b08e2db 100644 --- a/lib/ohai/util/file_helper.rb +++ b/lib/ohai/util/file_helper.rb @@ -25,8 +25,12 @@ module Ohai paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] paths.each do |path| filename = File.join(path, cmd) - return filename if File.executable?(filename) + if File.executable?(filename) + Ohai::Log.debug("#{self.name} plugin: found #{cmd} at #{filename}") + return filename + end end + Ohai::Log.debug("#{self.name} plugin: did not find #{cmd}") false end end diff --git a/spec/unit/util/file_helper_spec.rb b/spec/unit/util/file_helper_spec.rb index be68a321..f6c91cb1 100644 --- a/spec/unit/util/file_helper_spec.rb +++ b/spec/unit/util/file_helper_spec.rb @@ -27,6 +27,7 @@ describe "Ohai::Util::FileHelper" do let(:file_helper) { FileHelperMock.new } before(:each) do + allow(file_helper).to receive(:name).and_return("Fakeclass") allow(File).to receive(:executable?).and_return(false) end |