Skip to content

Call site output for deprecation warnings #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/puppet/functions/deprecation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
end

def deprecation(key, message)
stacktrace = Puppet::Pops::PuppetStack.stacktrace()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidS I'm sorry I keep doing this to you, but ...

Evaluation Error: Error while evaluating a Function Call, uninitialized constant Puppet::Pops::PuppetStack
https://travis-ci.org/voxpupuli/puppet-gluster/jobs/177770318#L917

That's puppet 3 with future parser enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, thanks for catching that. I know how that happened: https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/spec/functions/deprecation_spec.rb#L3 is a little too optimistic...

:-(

We'll retry tomorrow.

file = stacktrace[0]
line = stacktrace[1]
output_message = "#{message} at #{file}:#{line}"
# depending on configuration setting of strict
case Puppet.settings[:strict]
when :off
# do nothing
when :error
fail("deprecation. #{key}. #{message}")
fail("deprecation. #{key}. #{output_message}")
else
unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
Puppet.deprecation_warning(message, key)
Puppet.deprecation_warning(output_message, key)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
end

it "should show the error message" do
expect(@result.stderr).to match(/deprecation. key. message/)
expect(@result.stderr).to match(/deprecation. key. message at/)
end

describe file("#{test_file}") do
Expand All @@ -53,7 +53,7 @@
end

it "should show the error message" do
expect(@result.stderr).to match(/Warning: message/)
expect(@result.stderr).to match(/Warning: message at /)
end

describe file("#{test_file}") do
Expand Down