Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SDK-325) Validate all should run all validators #230

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/pdk/cli/validate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ module PDK::CLI
PDK::Util::Bundler.ensure_bundle!

validators.each do |validator|
exit_code = validator.invoke(report, options)
break if exit_code != 0
validator_exit_code = validator.invoke(report, options)
exit_code = validator_exit_code if validator_exit_code != 0
end

report_formats.each do |format|
Expand Down
66 changes: 66 additions & 0 deletions spec/acceptance/validate_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,70 @@ class validate_all { }
its(:stderr) { is_expected.to match(%r{Checking Ruby code style}i) }
end
end

context 'with a puppet syntax failure should still run all validators' do
include_context 'in a new module', 'validate_all'

init_pp = File.join('manifests', 'init.pp')

before(:all) do
File.open(init_pp, 'w') do |f|
f.puts <<-EOS
# foo
class validate_all {
Fails here because of gibberish
}
EOS
end
end

describe command('pdk validate') do
its(:exit_status) { is_expected.not_to eq(0) }
its(:stderr) { is_expected.to match(%r{Running all available validators}i) }
its(:stderr) { is_expected.to match(%r{Checking metadata \(metadata\.json\)}i) }
its(:stderr) { is_expected.to match(%r{Checking Puppet manifest syntax}i) }
its(:stdout) { is_expected.to match(%r{Error: This Name has no effect}i) }
its(:stdout) { is_expected.to match(%r{Error: This Type-Name has no effect}i) }
its(:stdout) { is_expected.to match(%r{Error: Language validation logged 2 errors. Giving up}i) }
its(:stderr) { is_expected.not_to match(%r{Checking Puppet manifest style}i) }
its(:stderr) { is_expected.to match(%r{Checking Ruby code style}i) }
end

describe command('pdk validate --format junit') do
its(:exit_status) { is_expected.not_to eq(0) }
its(:stderr) { is_expected.to match(%r{Running all available validators}i) }
its(:stderr) { is_expected.to match(%r{Checking metadata \(metadata\.json\)}i) }
its(:stderr) { is_expected.to match(%r{Checking Puppet manifest syntax}i) }
its(:stderr) { is_expected.not_to match(%r{Checking Puppet manifest style}i) }
its(:stderr) { is_expected.to match(%r{Checking Ruby code style}i) }
its(:stdout) { is_expected.to pass_validation(junit_xsd) }

its(:stdout) do
is_expected.to have_junit_testsuite('puppet-syntax').with_attributes(
'failures' => eq(3),
'tests' => eq(3),
)
end

its(:stdout) do
is_expected.to have_junit_testcase.in_testsuite('puppet-syntax').with_attributes(
'classname' => 'puppet-syntax',
'name' => a_string_starting_with(init_pp),
).that_failed(
'type' => 'Error',
'message' => a_string_matching(%r{This Name has no effect}i),
)
end

its(:stdout) do
is_expected.to have_junit_testcase.in_testsuite('puppet-syntax').with_attributes(
'classname' => 'puppet-syntax',
'name' => a_string_starting_with(init_pp),
).that_failed(
'type' => 'Error',
'message' => a_string_matching(%r{This Type-Name has no effect}i),
)
end
end
end
end