mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
Merge pull request #1017 from chef/chris-rock/cli-report-show-errors
always display error message
This commit is contained in:
commit
ec2e994dae
2 changed files with 20 additions and 17 deletions
|
@ -386,10 +386,18 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
control_result = control[:results]
|
control_result = control[:results]
|
||||||
title = control_result[0][:code_desc].split[0..1].join(' ')
|
title = control_result[0][:code_desc].split[0..1].join(' ')
|
||||||
puts ' ' + title
|
puts ' ' + title
|
||||||
|
# iterate over all describe blocks in anonoymous control block
|
||||||
control_result.each do |test|
|
control_result.each do |test|
|
||||||
control_id = ''
|
control_id = ''
|
||||||
|
# display exceptions
|
||||||
|
unless test[:exception].nil?
|
||||||
|
test_result = test[:message]
|
||||||
|
else
|
||||||
|
# determine title
|
||||||
test_result = test[:code_desc].split[2..-1].join(' ')
|
test_result = test[:code_desc].split[2..-1].join(' ')
|
||||||
test_result = test[:message] unless test[:exception].nil?
|
# show error message
|
||||||
|
test_result += "\n" + test[:message] unless test[:message].nil?
|
||||||
|
end
|
||||||
status_indicator = test[:status_type]
|
status_indicator = test[:status_type]
|
||||||
print_line(
|
print_line(
|
||||||
color: @colors[status_indicator] || '',
|
color: @colors[status_indicator] || '',
|
||||||
|
|
|
@ -57,19 +57,14 @@ Summary: \e[32m0 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
||||||
out = inspec('exec ' + File.join(profile_path, 'spec_only'))
|
out = inspec('exec ' + File.join(profile_path, 'spec_only'))
|
||||||
out.stderr.must_equal ''
|
out.stderr.must_equal ''
|
||||||
out.exit_status.must_equal 1
|
out.exit_status.must_equal 1
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_equal "
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "Target: local://"
|
||||||
Target: local://
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "working should"
|
||||||
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✔ eq \"working\""
|
||||||
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "skippy This"
|
||||||
working should
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "○ will be skipped intentionally."
|
||||||
\e[32m ✔ eq \"working\"\e[0m
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "failing should"
|
||||||
skippy This
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ eq \"as intended\""
|
||||||
\e[37m ○ will be skipped intentionally.\e[0m
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "Summary: \e[32m1 successful\e[0m, \e[31m1 failures\e[0m, \e[37m1 skipped\e[0m"
|
||||||
failing should
|
|
||||||
\e[31m ✖ eq \"as intended\"\e[0m
|
|
||||||
|
|
||||||
Summary: \e[32m1 successful\e[0m, \e[31m1 failures\e[0m, \e[37m1 skipped\e[0m
|
|
||||||
"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'executes only specified controls' do
|
it 'executes only specified controls' do
|
||||||
|
@ -153,7 +148,7 @@ Summary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
||||||
|
|
||||||
it 'should print all the results' do
|
it 'should print all the results' do
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ tmp-1.0: Create /tmp directory (1 failed)\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ tmp-1.0: Create /tmp directory (1 failed)\e[0m"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ should not be directory\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ should not be directory"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ undefined method `should_nota'"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ undefined method `should_nota'"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ expected `File /tmp.directory?` to return false, got true\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ expected `File /tmp.directory?` to return false, got true\e[0m"
|
||||||
end
|
end
|
||||||
|
@ -164,7 +159,7 @@ Summary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
||||||
|
|
||||||
it 'should print all the results' do
|
it 'should print all the results' do
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ tmp-1.0: Create /tmp directory (1 failed)\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ tmp-1.0: Create /tmp directory (1 failed)\e[0m"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ should not be directory\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ should not be directory"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ undefined method `should_nota'"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ undefined method `should_nota'"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ expected `File /tmp.directory?` to return false, got true\e[0m"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ expected `File /tmp.directory?` to return false, got true\e[0m"
|
||||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✔ profiled-1: Create /tmp directory (profile d)"
|
out.stdout.force_encoding(Encoding::UTF_8).must_include "✔ profiled-1: Create /tmp directory (profile d)"
|
||||||
|
|
Loading…
Reference in a new issue