diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-07-27 11:34:32 -0700 |
|---|---|---|
| committer | markus <markus@AVA-351181.(none)> | 2010-08-03 15:19:31 -0700 |
| commit | 00ebf01227745edc84084d10a9d8be7439551b0f (patch) | |
| tree | 5e334b8f01f4091bd1e25fa2b36731bf4a800bfd | |
| parent | e32320ee2c65275e3c695c555f506a499209efa1 (diff) | |
[#4344] Fix for failing templates when module name matches file in local dir.
When the name of a module matches the name of a file in the local
directory, puppet agent would sometimes try to read that file and
interpret it as puppet code. This happened because files.rb was
unintentionally permitting puppet files without an extension. Fixed
by changing the glob pattern to only permit ".pp" and ".rb"
extensions.
| -rw-r--r-- | lib/puppet/parser/files.rb | 2 | ||||
| -rw-r--r-- | spec/unit/parser/files_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/parser/type_loader_spec.rb | 2 | ||||
| -rwxr-xr-x | test/language/parser.rb | 12 | ||||
| -rwxr-xr-x | test/lib/puppettest.rb | 4 |
5 files changed, 13 insertions, 13 deletions
diff --git a/lib/puppet/parser/files.rb b/lib/puppet/parser/files.rb index 9ef05e102..f34683153 100644 --- a/lib/puppet/parser/files.rb +++ b/lib/puppet/parser/files.rb @@ -24,7 +24,7 @@ module Puppet::Parser::Files # Than that would be a "no." end abspat = File::expand_path(start, cwd) - [nil, Dir.glob(abspat + (File.extname(abspat).empty? ? '{,.pp,.rb}' : '' )).uniq.reject { |f| FileTest.directory?(f) }] + [nil, Dir.glob(abspat + (File.extname(abspat).empty? ? '{.pp,.rb}' : '' )).uniq.reject { |f| FileTest.directory?(f) }] end # Find the concrete file denoted by +file+. If +file+ is absolute, diff --git a/spec/unit/parser/files_spec.rb b/spec/unit/parser/files_spec.rb index fcfbfa613..3eb0db07e 100644 --- a/spec/unit/parser/files_spec.rb +++ b/spec/unit/parser/files_spec.rb @@ -154,7 +154,7 @@ describe Puppet::Parser::Files do it "should match against provided fully qualified patterns" do pattern = @basepath + "/fully/qualified/pattern/*" - Dir.expects(:glob).with(pattern+'{,.pp,.rb}').returns(%w{my file list}) + Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns(%w{my file list}) Puppet::Parser::Files.find_manifests(pattern)[1].should == %w{my file list} end @@ -168,7 +168,7 @@ describe Puppet::Parser::Files do pattern = @basepath + "/fully/qualified/pattern/*" file = @basepath + "/my/file" dir = @basepath + "/my/directory" - Dir.expects(:glob).with(pattern+'{,.pp,.rb}').returns([file, dir]) + Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns([file, dir]) FileTest.expects(:directory?).with(file).returns(false) FileTest.expects(:directory?).with(dir).returns(true) Puppet::Parser::Files.find_manifests(pattern)[1].should == [file] @@ -176,7 +176,7 @@ describe Puppet::Parser::Files do it "should return files once only" do pattern = @basepath + "/fully/qualified/pattern/*" - Dir.expects(:glob).with(pattern+'{,.pp,.rb}').returns(%w{one two one}) + Dir.expects(:glob).with(pattern+'{.pp,.rb}').returns(%w{one two one}) Puppet::Parser::Files.find_manifests(pattern)[1].should == %w{one two} end end diff --git a/spec/unit/parser/type_loader_spec.rb b/spec/unit/parser/type_loader_spec.rb index 8f005d551..83006b37b 100644 --- a/spec/unit/parser/type_loader_spec.rb +++ b/spec/unit/parser/type_loader_spec.rb @@ -192,7 +192,7 @@ describe Puppet::Parser::TypeLoader do end it "should be able to add classes to the current resource type collection" do - file = tmpfile("simple_file") + file = tmpfile("simple_file.pp") File.open(file, "w") { |f| f.puts "class foo {}" } @loader.import(file) diff --git a/test/language/parser.rb b/test/language/parser.rb index 5a433c724..8cda8eeb2 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -97,7 +97,7 @@ class TestParser < Test::Unit::TestCase } 4.times { |i| - path = File.join(basedir, subdir, "subfile#{i}") + path = File.join(basedir, subdir, "subfile#{i}.pp") mkmanifest(path) } @@ -137,8 +137,8 @@ class TestParser < Test::Unit::TestCase end def test_importedclasses - imported = tempfile - importer = tempfile + imported = tempfile '.pp' + importer = tempfile '.pp' made = tempfile @@ -655,9 +655,9 @@ file { "/tmp/yayness": end def test_multiple_imports_on_one_line - one = tempfile - two = tempfile - base = tempfile + one = tempfile '.pp' + two = tempfile '.pp' + base = tempfile '.pp' File.open(one, "w") { |f| f.puts "$var = value" } File.open(two, "w") { |f| f.puts "$var = value" } File.open(base, "w") { |f| f.puts "import '#{one}', '#{two}'" } diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index e31a31902..294d0ef8d 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -227,14 +227,14 @@ module PuppetTest #Facter.stubs(:to_hash).returns({}) end - def tempfile + def tempfile(suffix = '') if defined?(@@tmpfilenum) @@tmpfilenum += 1 else @@tmpfilenum = 1 end - f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s) + f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s + suffix) @@tmpfiles ||= [] @@tmpfiles << f f |
