mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
print profile info before test results (inherited profiles)
This commit is contained in:
parent
da63276070
commit
47c6427082
2 changed files with 32 additions and 15 deletions
|
@ -287,6 +287,7 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
@missing_controls = []
|
@missing_controls = []
|
||||||
@anonymous_tests = []
|
@anonymous_tests = []
|
||||||
@control_tests = []
|
@control_tests = []
|
||||||
|
@profile_printed = false
|
||||||
super(*args)
|
super(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -296,17 +297,7 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
print_tests
|
print_tests
|
||||||
output.puts('')
|
output.puts('')
|
||||||
|
|
||||||
@profiles_info.each do |profile|
|
print_profiles_info if !@profile_printed
|
||||||
next if profile[:already_printed]
|
|
||||||
@current_profile = profile
|
|
||||||
next unless print_current_profile
|
|
||||||
print_line(
|
|
||||||
color: '', indicator: @indicators['empty'], id: '', profile: '',
|
|
||||||
summary: 'No tests executed.'
|
|
||||||
) if @current_control.nil?
|
|
||||||
output.puts('')
|
|
||||||
end
|
|
||||||
|
|
||||||
controls_res = controls_summary
|
controls_res = controls_summary
|
||||||
tests_res = tests_summary
|
tests_res = tests_summary
|
||||||
|
|
||||||
|
@ -463,9 +454,8 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
def flush_current_control
|
def flush_current_control
|
||||||
return if @current_control.nil?
|
return if @current_control.nil?
|
||||||
|
|
||||||
prev_profile = @current_profile
|
|
||||||
@current_profile = @profiles_info.find { |i| i[:id] == @current_control[:profile_id] }
|
@current_profile = @profiles_info.find { |i| i[:id] == @current_control[:profile_id] }
|
||||||
print_current_profile if prev_profile != @current_profile
|
print_current_profile if !@profile_printed
|
||||||
|
|
||||||
fails, skips, passes, summary_indicator = current_control_infos
|
fails, skips, passes, summary_indicator = current_control_infos
|
||||||
summary = current_control_summary(fails, skips)
|
summary = current_control_summary(fails, skips)
|
||||||
|
@ -495,14 +485,32 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
output.puts(before + connection.uri + after)
|
output.puts(before + connection.uri + after)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def print_profiles_info
|
||||||
|
@profiles_info.each do |profile|
|
||||||
|
next if profile[:already_printed]
|
||||||
|
@current_profile = profile
|
||||||
|
next unless print_current_profile
|
||||||
|
print_line(
|
||||||
|
color: '', indicator: @indicators['empty'], id: '', profile: '',
|
||||||
|
summary: 'No tests executed.'
|
||||||
|
) if @current_control.nil?
|
||||||
|
output.puts('')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def print_current_profile
|
def print_current_profile
|
||||||
profile = @current_profile
|
profile = @current_profile
|
||||||
return false if profile.nil?
|
if profile.nil?
|
||||||
|
print_profiles_info
|
||||||
|
@profile_printed = true
|
||||||
|
return true
|
||||||
|
end
|
||||||
output.puts ''
|
output.puts ''
|
||||||
profile[:already_printed] = true
|
profile[:already_printed] = true
|
||||||
|
|
||||||
if profile[:name].nil?
|
if profile[:name].nil?
|
||||||
print_target('Target: ', "\n\n")
|
print_target('Target: ', "\n\n")
|
||||||
|
@profile_printed = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -515,6 +523,7 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
output.puts 'Version: ' + (profile[:version] || 'unknown')
|
output.puts 'Version: ' + (profile[:version] || 'unknown')
|
||||||
print_target('Target: ', "\n")
|
print_target('Target: ', "\n")
|
||||||
output.puts
|
output.puts
|
||||||
|
@profile_printed = true
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,14 @@ Test Summary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'given an inherited profile' do
|
||||||
|
let(:out) { inspec('exec ' + simple_inheritance) }
|
||||||
|
|
||||||
|
it 'should print the profile information and then the test results' do
|
||||||
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "local://\n\n\n\e[31;1m ✖ tmp-1.0: Create /tmp directory (1 failed)\e[0m\n\e[31;1m ✖ File /tmp should not be directory\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'using namespaced resources' do
|
describe 'using namespaced resources' do
|
||||||
it 'works' do
|
it 'works' do
|
||||||
out = inspec('exec ' + File.join(profile_path, 'dependencies', 'resource-namespace') + ' --no-create-lockfile')
|
out = inspec('exec ' + File.join(profile_path, 'dependencies', 'resource-namespace') + ' --no-create-lockfile')
|
||||||
|
|
Loading…
Reference in a new issue