[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Luke Kanies
luke at puppetlabs.com
Tue May 10 08:08:32 UTC 2011
The following commit has been merged in the experimental branch:
commit 29268f3fda3c6e29f60d05e5aa387ff0424e7b1e
Author: Luke Kanies <luke at puppetlabs.com>
Date: Fri Mar 25 12:39:13 2011 -0700
Fixing Module#path detection
For some reason FileTest.exist? was returning false,
and FileTest.directory? returns true.
I've also added much better tests for this behavior.
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
Reviewed-by: Daniel Pittman <daniel at puppetlabs.com>
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index 43266b2..059591e 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -138,7 +138,7 @@ class Puppet::Module
# Find this module in the modulepath.
def path
- environment.modulepath.collect { |path| File.join(path, name) }.find { |d| FileTest.exist?(d) }
+ environment.modulepath.collect { |path| File.join(path, name) }.find { |d| FileTest.directory?(d) }
end
# Find all plugin directories. This is used by the Plugins fileserving mount.
diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb
index 54f5444..f3120e1 100755
--- a/spec/unit/module_spec.rb
+++ b/spec/unit/module_spec.rb
@@ -1,8 +1,11 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'puppet_spec/files'
describe Puppet::Module do
+ include PuppetSpec::Files
+
before do
# This is necessary because of the extra checks we have for the deprecated
# 'plugins' directory
@@ -267,17 +270,39 @@ describe Puppet::Module do
end
it "should return the path to the first found instance in its environment's module paths as its path" do
+ dir = tmpdir("deep_path")
+ first = File.join(dir, "first")
+ second = File.join(dir, "second")
+
+ FileUtils.mkdir_p(first)
+ FileUtils.mkdir_p(second)
+ Puppet[:modulepath] = "#{first}:#{second}"
+
+ modpath = File.join(first, "foo")
+ FileUtils.mkdir_p(modpath)
+
+ # Make a second one, which we shouldn't find
+ FileUtils.mkdir_p(File.join(second, "foo"))
+
mod = Puppet::Module.new("foo")
- env = mock 'environment'
- mod.stubs(:environment).returns env
+ mod.path.should == modpath
+ end
+
+ it "should be able to find itself in a directory other than the first directory in the module path" do
+ dir = tmpdir("deep_path")
+ first = File.join(dir, "first")
+ second = File.join(dir, "second")
- env.expects(:modulepath).returns %w{/a /b /c}
+ FileUtils.mkdir_p(first)
+ FileUtils.mkdir_p(second)
+ Puppet[:modulepath] = "#{first}:#{second}"
- FileTest.expects(:exist?).with("/a/foo").returns false
- FileTest.expects(:exist?).with("/b/foo").returns true
- FileTest.expects(:exist?).with("/c/foo").never
+ modpath = File.join(second, "foo")
+ FileUtils.mkdir_p(modpath)
- mod.path.should == "/b/foo"
+ mod = Puppet::Module.new("foo")
+ mod.should be_exist
+ mod.path.should == modpath
end
it "should be considered existent if it exists in at least one module path" do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list