diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-08-16 12:40:06 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-19 13:52:59 -0700 |
commit | 2681ca5360428db071aaa66614c21f6be581c1cc (patch) | |
tree | d303dca23c628e35162e0a8143de1445d1b601b3 | |
parent | 3812fc35eae962938041256f8974bc94f41a3326 (diff) | |
download | puppet-2681ca5360428db071aaa66614c21f6be581c1cc.tar.gz puppet-2681ca5360428db071aaa66614c21f6be581c1cc.tar.xz puppet-2681ca5360428db071aaa66614c21f6be581c1cc.zip |
Fix posix exec provider spec failures on Windows
These specs were assuming that paths such as /foo were always absolute, which
is not the case on Windows. Thus, when run on Windows, the provider was
complaining about receiving relative paths when it expected absolute, rather
than succeeding or failing in the intended way. Now we expand all paths we want
to be absolute, to guarantee they will be absolute everywhere.
Also, some specs were failing because they were trying to test the case where a
file isn't executable. That's not something we can reliably check on Windows,
so instead just stub the appropriate executable? methods.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
(cherry picked from commit e9b558dd35eec6e221aef9de3f300a5843347454)
-rwxr-xr-x | spec/unit/provider/exec/posix_spec.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/spec/unit/provider/exec/posix_spec.rb b/spec/unit/provider/exec/posix_spec.rb index 876b9724d..883e3c716 100755 --- a/spec/unit/provider/exec/posix_spec.rb +++ b/spec/unit/provider/exec/posix_spec.rb @@ -11,7 +11,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do command end - let(:resource) { Puppet::Type.type(:exec).new(:title => '/foo') } + let(:resource) { Puppet::Type.type(:exec).new(:title => File.expand_path('/foo')) } let(:provider) { described_class.new(resource) } before :each do @@ -34,7 +34,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do it "should pass if command is fully qualifed" do provider.resource[:path] = ['/bogus/bin'] - provider.validatecmd("/bin/blah/foo") + provider.validatecmd(File.expand_path("/bin/blah/foo")) end end @@ -55,6 +55,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do it "should fail if the command isn't executable" do FileUtils.touch(command) + File.stubs(:executable?).with(command).returns(false) expect { provider.run(command) }.to raise_error(ArgumentError, "'#{command}' is not executable") end @@ -80,6 +81,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do it "should fail if the command is in the path but not executable" do command = tmpfile('foo') FileUtils.touch(command) + FileTest.stubs(:executable?).with(command).returns(false) resource[:path] = [File.dirname(command)] filename = File.basename(command) @@ -102,7 +104,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do it "should fail if quoted command doesn't exist" do provider.resource[:path] = ['/bogus/bin'] - command = "/foo bar --sillyarg=true --blah" + command = "#{File.expand_path('/foo')} bar --sillyarg=true --blah" expect { provider.run(%Q["#{command}"]) }.to raise_error(ArgumentError, "Could not find command '#{command}'") end |