inspec/lib/inspec/enhanced_outcomes.rb
Nikita Mathur 15433e8661
Foreport 6229 to inspec 6 (#6277)
* Not applicable if logic addition

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

* Changes from not applicable if to only applicable if

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

* Fix to enable placing only_applicable_if at any position in control and for keeping impact zero intact

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

* Doc change added for only_applicable_if

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

* Doc Review

Signed-off-by: Deepa Kumaraswamy <dkumaras@progress.com>

* Added generic examples that supports cross platform for testing

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

* Yet another build fix due to changes in test

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Signed-off-by: Deepa Kumaraswamy <dkumaras@progress.com>
Co-authored-by: Deepa Kumaraswamy <dkumaras@progress.com>
2022-10-20 14:07:10 -04:00

20 lines
551 B
Ruby

module Inspec
module EnhancedOutcomes
def self.determine_status(results, impact)
# No-op exception occurs in case of not_applicable_if
if results.any? { |r| !r[:exception].nil? && !r[:backtrace].nil? && r[:resource_class] != "noop" }
"error"
elsif !impact.nil? && impact.to_f == 0.0
"not_applicable"
elsif results.all? { |r| r[:status] == "skipped" }
"not_reviewed"
elsif results.any? { |r| r[:status] == "failed" }
"failed"
else
"passed"
end
end
end
end