summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-12-05 15:24:00 -0800
committertyler-ball <tyleraball@gmail.com>2014-12-08 14:57:27 -0800
commita6a9747f76efd46b4421320748083a3a4b269ead (patch)
tree4ae3e10ef707f15e794ea807da012eb54e261d84
parent24daf0b67132bb16712513be3fe0d6f891ac9808 (diff)
downloadchef-a6a9747f76efd46b4421320748083a3a4b269ead.tar.gz
Adding number failed to exception
-rw-r--r--lib/chef/audit/runner.rb10
-rw-r--r--lib/chef/client.rb4
-rw-r--r--lib/chef/exceptions.rb4
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index 28ed5897d9..e15b3103f8 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -33,10 +33,18 @@ class Chef
do_run
end
- def audits_failed?
+ def failed?
RSpec.world.reporter.failed_examples.size > 0
end
+ def num_failed
+ RSpec.world.reporter.failed_examples.size
+ end
+
+ def num_total
+ RSpec.world.reporter.examples.size
+ end
+
private
# Prepare to run audits:
# - Require files
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 8a55f5fd90..634773cf80 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -358,7 +358,9 @@ class Chef
Chef::Log.info("Starting audit phase")
auditor = Chef::Audit::Runner.new(run_context)
auditor.run
- raise Chef::Exceptions::AuditsFailed if auditor.audits_failed?
+ if auditor.failed?
+ raise Chef::Exceptions::AuditsFailed.new(auditor.num_failed, auditor.num_total)
+ end
@events.audit_phase_complete
rescue Exception => e
Chef::Log.error("Audit phase failed with error message: #{e.message}")
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 0aae8d9484..ef957ec502 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -391,8 +391,8 @@ class Chef
end
end
class AuditsFailed < RuntimeError
- def initialize
- super "There were audit example failures. Results were still sent to the server."
+ def initialize(num_failed, num_total)
+ super "Audit phase found failures - #{num_failed}/#{num_total} audits failed"
end
end