Enable coverage report generation for Jenkins

This change fixes the regression introduced by
I814667283ccfc6ebd7c16d961270f688e9fb9c4c in which the rspec coverage
information was no longer being written out. Additionally this change
enables coverage report information to be generaged by the Jenkins jobs
as part of the default run via fuel_noop_tests.sh. This change will
allow us to update the jobs to capture the information with Jenkins and
report on trends.

Change-Id: I6cc729d7ff2928bdf78ee17487f2158b4ef12490
Closes-Bug: #1524967
Related-Bug: #1506557
This commit is contained in:
Alex Schultz 2015-12-10 15:29:24 -07:00
parent 15d966e164
commit e30a4e6352
4 changed files with 34 additions and 1 deletions

View File

@ -20,11 +20,31 @@ class Noop
end
SimpleCov.at_exit do
puts "-"*80
puts "SimpleCov Coverage Report"
SimpleCov.result.format!
puts "Total coverage percent: #{SimpleCov.result.covered_percent.round 2}"
puts "-"*80
end
end
def coverage_rspec(file_name)
coverage_prepare
# capture the rspec coverage report
puppet_coverage_report = capture_stdout do
RSpec::Puppet::Coverage.report!
end
# write the rspec coverage report out to a file
File.open("#{coverage_base_dir}/#{file_name}", "w") { |file|
file.write(puppet_coverage_report.string)
}
# also print it out to the console
puts "-"*80
puts "RSpec Coverage Report for #{file_name}"
puts puppet_coverage_report.string
puts "-"*80
end
end
extend Coverage
end

View File

@ -56,6 +56,15 @@ class Noop
lambda { ral_catalog }
end
def capture_stdout
output = StringIO.new
$stdout = output
yield
return output
ensure
$stdout = STDOUT
end
end
extend Helpers
end

View File

@ -46,3 +46,7 @@ RSpec.configure do |c|
end
Noop.coverage_simplecov if ENV['SPEC_COVERAGE']
at_exit {
Noop.coverage_rspec ENV['SPEC_ASTUTE_FILE_NAME'] if ENV['SPEC_COVERAGE']
}

View File

@ -5,5 +5,5 @@ DIR=`dirname $0`
echo 'Ruby version:'
ruby --version
"${DIR}/fuel_noop_tests.rb" -b -d -u -m ${@}
"${DIR}/fuel_noop_tests.rb" -b -d -u -O -m ${@}