Method: Inspec::RunnerRspec#exit_code

Defined in:
lib/inspec/runner_rspec.rb

#exit_codeint

Return a proper exit code to the runner

Returns:

  • (int)

    exit code



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/inspec/runner_rspec.rb', line 84

def exit_code
  return @rspec_exit_code if @formatter.results.empty?
  stats = @formatter.results[:statistics][:controls]
  skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == 'skipped'
  if stats[:failed][:total] == 0 && stats[:skipped][:total] == 0 && !skipped
    0
  elsif stats[:failed][:total] > 0
    @conf['distinct_exit'] ? 100 : 1
  elsif stats[:skipped][:total] > 0 || skipped
    @conf['distinct_exit'] ? 101 : 0
  else
    @rspec_exit_code
  end
end