summaryrefslogtreecommitdiff
path: root/spec/unit/util/logging_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-06-16(PUP-2557) Issue deprecation warning for AST::Node inheritanceJosh Partlow1-0/+38
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.
2014-06-04(PUP-2650) Add disable_warnings settingAdrien Thebo1-0/+6
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'.
2014-04-16(PUP-2282) Allow deprecation warnings to supply optional keyJosh Partlow1-3/+13
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.
2014-03-31(maint) Display full trace to deprecated codeAndrew Parker1-1/+1
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.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
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,'
2012-09-10(#16027) Restore function context to backtracesDaniel Pittman1-6/+6
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>
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
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.
2012-05-04(#13341) Log nested exceptionsPatrick Carlisle1-0/+26
2012-02-08Merge pull request #456 from ↵Daniel Pittman1-3/+9
cprice-puppet/refactor/master/12359-improve-backtrace-logging Refactor/master/12359 improve backtrace logging
2012-02-07Clear deprecation warnings after each test.Patrick Carlisle1-4/+0
2012-02-06(#12359) Improve logging of backtracescprice1-3/+9
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".
2012-02-02(#12309) Refactor deprecated uses of Util.executecprice1-4/+8
* 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
2011-10-05Change tests to not use 'mount' providerJosh Cooper1-6/+6
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.
2011-08-19Maint: Tagged spec tests that are known to fail on WindowsJosh Cooper1-2/+2
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
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
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.
2011-04-12(#5027) Use Puppet#warning for deprecation_wanring instead of Kernel#warnNick Lewis1-4/+4
Using warning, the deprecation warnings will appear in logs and in color. Paired-With: Jesse Wolfe
2011-04-12(#5027) Spell deprecation correctlyNick Lewis1-6/+6
Paired-With: Jesse Wolfe
2011-04-12Step towards #5027 -- add Logging#deprication_warning facilityMarkus Roberts1-0/+25
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.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
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>
2011-03-22maint: Change code for finding spec_helper to work with Ruby 1.9Matt Robinson1-1/+1
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>
2010-12-30(#5715) Removed Puppet::Util::Log#version.Paul Berry1-1/+1
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.
2010-07-09Code smell: Two space indentationMarkus Roberts1-57/+57
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
2010-07-07[#4114] Fix failures in the unit testsMatt Robinson1-0/+1
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.
2010-07-07[#4114] Added queueing to the logNick Lewis1-0/+6
The log will now queue any log messages created when there is no destination, and will flush the queue when a destination is added.
2010-06-28[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts1-0/+88
Part 2 re-did the change on the spec files, which it shouldn't have.
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-88/+0
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
2010-06-28maint: Fixes some noisy specsNick Lewis1-1/+1
This change removes some irrelevant output (debugging information, warnings, etc) from a few specs.
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts1-0/+88
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