Age | Commit message (Collapse) | Author | Files | Lines |
|
Puppet.deprecation_warning constructs an internal stack trace and is
mostly useful for internal deprecation notices as opposed to notices of
deprecation in Puppet manifests. Because of this, a regular warning was
being used in its place for the node inheritance deprecation. But this
would bypass limits on deprecation warnings and the ability to suppress
deprecation warnings added in PUP-2650.
This commit adds a puppet_deprecation_warning() which shares code now
with deprecation_warning, and which traces to the file and line of the
node's context. The AST::Node inheritance warning uses this method now.
|
|
This commit adds a new setting that allows users to disable different
classes of warnings. Right now the only supported type of warning that
can be disabled is 'deprecations'.
|
|
Puppet::Util::Logging#deprecation_warning keeps track of issued
deprecations keyed by the originating code line. This works reasonably
well for tracing API deprecations, but can cause a problem for
notifications coming from internal calls which might happen to be called
multiple times by other code sections. It also causes problems if the
same line of code issues different deprecation warnings (say by
interpolating some parameter into the message).
This patch allows an optional key string to be submitted with the
deprecation_warning which takes precedence over using the
originating call line as the key.
|
|
Sometimes the location that immediately triggered the deprecation
warning isn't enough information to understand what happened. This adds
the ability to see the full trace to the deprecation when --trace is
enabled.
|
|
Without this patch Ruby 1.9 is still complaining loudly about trying to
parse the spec files. The previous attempt to clean up this problem in
edc3ddf works for Ruby 1.8 but not 1.9.
I'd prefer to remove the shebang lines entirely, but doing so will cause
encoding errors in Ruby 1.9. This patch strives for a happy middle
ground of convincing Ruby it is actually working with Ruby while not
confusing it to think it should exec() to rspec.
This patch is the result of the following command run against the source
tree:
find spec -type f -print0 | \
xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
|
|
The changed implementation of `pretty_backtrace` was indeed prettier, but it
also lost information: the function context was dropped from the trace.
Since this is a debugging tool, and knowing the method tree is quite valuable
to understanding a problem, this restores it - and any extra context that Ruby
later decided it should add to the picture.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Without this patch some spec files are using `ruby -S rspec` and others
are using `rspec`.
We should standardize on a single form of the interpreter used for spec
files.
`ruby -S rspec` is the best choice because it correctly informs editors
such as Vim with Syntastic that the file is a Ruby file rather than an
Rspec file.
|
|
|
|
cprice-puppet/refactor/master/12359-improve-backtrace-logging
Refactor/master/12359 improve backtrace logging
|
|
|
|
There were a ton of places in the code where we were doing this:
rescue => detail
puts detail.backtrace if Puppet[:trace]
In addition to this not being very DRY, it was making it harder to debug the puppet master from within the acceptance testing framework (because when puppet is run in a daemon mode, stdout is swallowed... the "puts" messages were not showing up in the log files or anywhere else, so it was impossible to see the backtrace when something went wrong on the master).
This commit refactors all(?) occurrences of this pattern to call a new utility method: Puppet::Util::Logging.log_exception(), which provides one single code path for handling exception logging. It still only logs the backtrace if Puppet[:trace] == true, but it now logs it through the standard Puppet logging framework rather than via "puts".
|
|
* Improve logic of deprecation_warning
* Add utility method for logging deprecation warnings to a file
* Refactored all references of Puppet::Util.execute to call Puppet::Util::Execution.execute
|
|
Windows does not support a mount provider, which was causing these
tests to fail. The tests don't actually depend on the type of provider
used, so I switched it to use the 'host' and 'tidy' providers and
removed the fails_on_windows tag.
|
|
Many spec tests fail on Windows because there are no default
providers implemented for Windows yet. Several others are
failing due to Puppet::Util::Cacher not working correctly,
so for now the tests that are known to fail are marked with
:fails_on_windows => true. To skip these tests, you can run:
rspec --tag ~fails_on_windows spec
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 255c5b4663bd389d2c87a2d39ec350034421a6f0)
Conflicts:
spec/unit/resource/catalog_spec.rb
|
|
We now use a shebang of: #!/usr/bin/env rspec
This enables the direct execution of spec tests again, which was lost earlier
during the transition to more directly using the rspec2 runtime environment.
|
|
Using warning, the deprecation warnings will appear in logs and in color.
Paired-With: Jesse Wolfe
|
|
Paired-With: Jesse Wolfe
|
|
This commit adds a method analogous to Puppet.warn which 1) only logs each
message the first time it is received and 2) only logs the first 100 messages
it receives. Messages are logged via warn.
This could easily be made more flexible by making the hard limit and effective
log level user settable, if desired.
|
|
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we
can just stop. As a side-effect we can now avoid a whole pile of stupid things
to try and include the spec_helper.rb file...
...and then we can stop protecting spec_helper from evaluating twice, since we
now require it with a consistent name. Yay.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
|
|
Running the specs under Ruby 1.9 didn't work using the lambda to recurse
down directories to find the spec_helper. Standardizing the way to find
spec_helper like the rest of specs seemed like the way to go.
Here's the command line perl I used to make the change:
perl -p -i -e "s/Dir.chdir.*lambda.*spec_helper.*$/require
File.expand_path(File.dirname(__FILE__) + '\/..\/..\/spec_helper')/"
`find spec -name "*_spec.rb"`
Then I fixed the number of dots for files that weren't two levels from
the spec dir and whose tests failed.
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
|
|
This attribute was only relevant in reports, and in reports it was
redundant with Puppet::Transaction::Report#configuration_version and
Puppet::Transaction::Report#puppet_version.
|
|
Replaced 106806 occurances of ^( +)(.*$) with
The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people
who learned ruby in the 1900s) uses two-space indentation.
3 Examples:
The code:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
becomes:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
The code:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
becomes:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
The code:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
becomes:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
|
|
The initial commit changed the name of a method (close -> close_all) and
changed the way the array log destination worked before we saw that the
unit tests were using it differently.
|
|
The log will now queue any log messages created when there is no
destination, and will flush the queue when a destination is added.
|
|
Part 2 re-did the change on the spec files, which it shouldn't have.
|
|
Some spec files like active_record.rb had names that would confuse the
load path and get loaded instead of the intended implentation when the
spec was run from the same directory as the file.
Author: Matt Robinson <matt@puppetlabs.com>
Date: Fri Jun 11 15:29:33 2010 -0700
|
|
This change removes some irrelevant output (debugging information,
warnings, etc) from a few specs.
|
|
Some spec files like active_record.rb had names that would confuse the
load path and get loaded instead of the intended implentation when the
spec was run from the same directory as the file.
Author: Matt Robinson <matt@puppetlabs.com>
Date: Fri Jun 11 15:29:33 2010 -0700
|