summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyleen MacGugan <kmacgugan@chef.io>2015-03-02 13:25:26 -0800
committerKyleen MacGugan <kmacgugan@chef.io>2015-03-03 09:48:48 -0800
commitcd8df9a5c54011208320b01d0cbd49da9c5a2dcf (patch)
tree74fe96c257f2b303e00f9677ea01e7c76643448a
parentc2dfb56e730214266ae07a57a56e5889b1e6b85b (diff)
downloadchef-kyleen/audit-exclusion.tar.gz
Add /lib/chef/ to backtrace exclusion patterns for audit modekyleen/audit-exclusion
Exclusion pattern now includes anything with /lib/chef/ only fix spacing issue
-rw-r--r--lib/chef/audit/runner.rb5
-rw-r--r--spec/unit/audit/runner_spec.rb10
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index e7d1657d69..13ba95428c 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -45,6 +45,10 @@ class Chef
RSpec.world.reporter.examples.size
end
+ def exclusion_pattern
+ Regexp.new(".+[\\\/]lib[\\\/]chef[\\\/]")
+ end
+
private
# Prepare to run audits:
# - Require files
@@ -96,6 +100,7 @@ class Chef
RSpec.configure do |c|
c.color = Chef::Config[:color]
c.expose_dsl_globally = false
+ c.backtrace_exclusion_patterns << exclusion_pattern
end
end
diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb
index 801147bdb9..10d8a645a7 100644
--- a/spec/unit/audit/runner_spec.rb
+++ b/spec/unit/audit/runner_spec.rb
@@ -36,6 +36,15 @@ describe Chef::Audit::Runner do
RSpec::Core::Sandbox.sandboxed { ex.run }
end
+ context "when we run in audit mode" do
+ paths = [ "/opt/chef/lib/chef/", 'C:\windows/here/lib/chef/' , "/opt/chef/extra/folders/lib/chef/"]
+ it "excludes the current path from backtrace" do
+ paths.each do |path|
+ expect(runner.exclusion_pattern).to match(path)
+ end
+ end
+ end
+
describe "#initialize" do
it "correctly sets the run_context during initialization" do
expect(runner.instance_variable_get(:@run_context)).to eq(run_context)
@@ -72,6 +81,7 @@ describe Chef::Audit::Runner do
expect(RSpec.configuration.color).to eq(color)
expect(RSpec.configuration.expose_dsl_globally?).to eq(false)
+ expect(RSpec.configuration.backtrace_exclusion_patterns).to include(runner.exclusion_pattern)
expect(Specinfra.configuration.backend).to eq(:exec)
end