diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2010-04-13 08:51:17 -0700 |
|---|---|---|
| committer | Luke Kanies <luke@puppetlabs.com> | 2010-04-13 08:51:17 -0700 |
| commit | da00f682ce0d1778183f9cf7dbe6d2e133b11841 (patch) | |
| tree | 08822d84323dcb1a659ef7badd78f7526bb1681a | |
| parent | 9792915481ed757c56768f8f5e4fd100217b7232 (diff) | |
| download | puppet-da00f682ce0d1778183f9cf7dbe6d2e133b11841.tar.gz puppet-da00f682ce0d1778183f9cf7dbe6d2e133b11841.tar.xz puppet-da00f682ce0d1778183f9cf7dbe6d2e133b11841.zip | |
Making a Puppet::Module test more resilient
It would fail if a directory unexpectedly existed.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
| -rw-r--r-- | lib/puppet/module.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/module.rb | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index f30b862ef..e598a8e88 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -126,10 +126,10 @@ class Puppet::Module return find_init_manifest unless rest # Use init.pp rest ||= "init.pp" - p = File::join(path, MANIFESTS, rest) - result = Dir.glob(p).reject { |f| FileTest.directory?(f) } + full_path = File::join(path, MANIFESTS, rest) + result = Dir.glob(full_path).reject { |f| FileTest.directory?(f) } if result.size == 0 and rest !~ /\.pp$/ - result = Dir.glob(p + ".pp") + result = Dir.glob(full_path + ".pp") end result.flatten.compact end diff --git a/spec/unit/module.rb b/spec/unit/module.rb index e6623befd..85cc84116 100755 --- a/spec/unit/module.rb +++ b/spec/unit/module.rb @@ -405,6 +405,7 @@ describe Puppet::Module, "when finding matching manifests" do it "should return all manifests matching the glob pattern" do Dir.expects(:glob).with("/a/manifests/yay/*.pp").returns(%w{foo bar}) + FileTest.stubs(:directory?).returns false @mod.match_manifests("yay/*.pp").should == %w{foo bar} end |
