When autoload happens inside of another autoload, exceptions get caught in
Puppet::Util::Autoload#load 's exception handler, like this:
            rescue Exception => detail
                # I have no idea what's going on here, but different
versions
                # of ruby are raising different errors on missing files.
                unless detail.to_s =~ /^no such file/i
                    warn "Could not autoload %s: %s" % [name, detail]
                    if Puppet[:trace]
                        puts detail.backtrace
                    end
                end
                return named_file_is_missing(name)

If an exception is thrown in the topmost autoload, then the exception
bubbles up to wherever there happens to be a rescue, in this case it's
(usually?) Puppet::Util::Settings#use, like this:
            rescue => detail
                puts detail.backtrace if Puppet[:trace]
                Puppet.err "Could not create resources for managing Puppet's
files and directories in sections %s: %s" % [sections.inspect, detail]

                # We need some way to get rid of any resources created
during the catalog creation
                # but not cleaned up.
                return
            end

They both log the warning message, but only Kernel#warn is visible when you
run the unit tests.

On Tue, Dec 15, 2009 at 7:55 AM, Markus Roberts <[email protected]>wrote:

> On Tue, Dec 15, 2009 at 1:36 AM, Jesse Wolfe <[email protected]> wrote:
> > Puppet[:libdir] is nil due to stubbing, causing an exception in autoload.
> >
> > Depending on the order of loaded libs, sometimes this exception is
> > logged using Kernel#warn, but sometimes it's logged using Puppet.err
> > Only Kernel#warn writes to the terminal during unit testing!
>
> Did you determine the mechanism behind the indeterminate warning
> method?  Specifically, I'm wondering if this is something that could
> manifest in production, and should be forced by adding strategic
> requires in the libraries?
>
> > Signed-off-by: Jesse Wolfe <[email protected]>
> > ---
> >  spec/unit/application/puppetd.rb |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/spec/unit/application/puppetd.rb
> b/spec/unit/application/puppetd.rb
> > index e5a5167..ec2fd54 100755
> > --- a/spec/unit/application/puppetd.rb
> > +++ b/spec/unit/application/puppetd.rb
> > @@ -173,6 +173,7 @@ describe "puppetd" do
> >             Puppet.stubs(:info)
> >             FileTest.stubs(:exists?).returns(true)
> >             Puppet.stubs(:[])
> > +            Puppet.stubs(:[]).with(:libdir).returns("/dev/null/lib")
> >             Puppet.settings.stubs(:print_config?)
> >             Puppet.settings.stubs(:print_config)
> >             Puppet::SSL::Host.stubs(:ca_location=)
> > --
> > 1.6.5
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<puppet-dev%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
> >
> >
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<puppet-dev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to