summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-10-04 11:44:41 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-10-04 11:53:15 -0700
commitd43f7996b93c394df0bd0994ae7298fb35ad2c5e (patch)
tree6b57693d1cfdb43ae964abfe25e9ef4cbcfb6fbc
parentce9a6f97ab1784d8bd60eae8b60272c9875b1f84 (diff)
parent99c1019e1d3402ec8e476dc859d5aaef82ec4f69 (diff)
Partial merge to 2.6.2rc1 : Merge commit '99c1019' into next
This conflict was a little too complicated for diff to figure out, but the resolution is actually fairly mechanical. Some unit tests changed because they were mocking unnecessarily. Manually Resolved Conflicts: lib/puppet/util/rdoc/parser.rb spec/unit/util/rdoc/parser_spec.rb
-rw-r--r--lib/puppet/util/rdoc/parser.rb20
-rw-r--r--spec/integration/application/doc_spec.rb48
-rwxr-xr-xspec/unit/util/rdoc/parser_spec.rb7
3 files changed, 59 insertions, 16 deletions
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index 30da607d9..aca66163c 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -33,17 +33,19 @@ class Parser
# main entry point
def scan
- Puppet.info "rdoc: scanning #{@input_file_name}"
- if @input_file_name =~ /\.pp$/
- @parser = Puppet::Parser::Parser.new(Puppet[:environment])
- environment = @parser.environment
- @parser.file = @input_file_name
- @known_resource_types = environment.known_resource_types
- @parser.parse.instantiate('').each do |type|
- @known_resource_types.add type
+ environment = Puppet::Node::Environment.new
+ unless environment.known_resource_types.watching_file?(@input_file_name)
+ Puppet.info "rdoc: scanning #{@input_file_name}"
+ if @input_file_name =~ /\.pp$/
+ @parser = Puppet::Parser::Parser.new(environment)
+ @parser.file = @input_file_name
+ @known_resource_types = environment.known_resource_types
+ @parser.parse.instantiate('').each do |type|
+ @known_resource_types.add type
+ end
+ scan_top_level(@top_level)
end
end
- scan_top_level(@top_level)
@top_level
end
diff --git a/spec/integration/application/doc_spec.rb b/spec/integration/application/doc_spec.rb
new file mode 100644
index 000000000..cb9f47868
--- /dev/null
+++ b/spec/integration/application/doc_spec.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'puppet_spec/files'
+
+describe Puppet::Application::Doc do
+ include PuppetSpec::Files
+
+ it "should not generate an error when module dir overlaps parent of site.pp (#4798)" do
+ begin
+ # Note: the directory structure below is more complex than it
+ # needs to be, but it's representative of the directory structure
+ # used in bug #4798.
+ old_dir = Dir.getwd # Note: can't use chdir with a block because it will generate bogus warnings
+ tmpdir = tmpfile('doc_spec')
+ Dir.mkdir(tmpdir)
+ Dir.chdir(tmpdir)
+ site_file = 'site.pp'
+ File.open(site_file, 'w') do |f|
+ f.puts '# A comment'
+ end
+ modules_dir = 'modules'
+ Dir.mkdir(modules_dir)
+ rt_dir = File.join(modules_dir, 'rt')
+ Dir.mkdir(rt_dir)
+ manifests_dir = File.join(rt_dir, 'manifests')
+ Dir.mkdir(manifests_dir)
+ rt_file = File.join(manifests_dir, 'rt.pp')
+ File.open(rt_file, 'w') do |f|
+ f.puts '# A class'
+ f.puts 'class foo { }'
+ f.puts '# A definition'
+ f.puts 'define bar { }'
+ end
+
+ puppet = Puppet::Application[:doc]
+ Puppet[:modulepath] = modules_dir
+ Puppet[:manifest] = site_file
+ puppet.options[:mode] = :rdoc
+ puppet.expects(:exit).with(0)
+ puppet.run_command
+
+ File.should be_exist('doc')
+ ensure
+ Dir.chdir(old_dir)
+ end
+ end
+end
diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb
index 5dc083cab..7809c75a3 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -16,17 +16,12 @@ describe RDoc::Parser do
end
describe "when scanning files" do
- before do
- @environment = Puppet::Node::Environment.new("foo")
- end
-
it "should parse puppet files with the puppet parser" do
@parser.stubs(:scan_top_level)
parser = stub 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
parser.expects(:file=).with("module/manifests/init.pp")
- parser.expects(:environment).returns(@environment)
@parser.scan
end
@@ -34,7 +29,6 @@ describe RDoc::Parser do
it "should scan the ast for Puppet files" do
parser = stub_everything 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
- parser.expects(:environment).returns(@environment)
parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
@parser.expects(:scan_top_level)
@@ -45,7 +39,6 @@ describe RDoc::Parser do
it "should return a PuppetTopLevel to RDoc" do
parser = stub_everything 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
- parser.expects(:environment).returns(@environment)
parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
@parser.expects(:scan_top_level)