Add coverage reports to tests

This change adds simplecov to show the coverage of the noop test files
and also includes the output from the rspec-puppet reports into the
coverage/ folder.

The simplecov report is a report that is merged together based on the
entire noop test run. It will show where we have astute.yaml gaps for
our given noop spec tests.

The rspec-puppet reports are named based on the astute.yaml file that
was used to generate each report.

Change-Id: I9dda550c960fb2742f1f0862305e144a3fb1d9d6
Closes-Bug: #1506557
This commit is contained in:
Alex Schultz 2015-10-15 13:21:00 -05:00
parent 5dcc8f43fb
commit 4847f1478d
4 changed files with 17 additions and 3 deletions

View File

@ -1,2 +1,3 @@
deprecations.log
Gemfile.lock
coverage

View File

@ -3,12 +3,13 @@ source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper'
gem 'puppet-lint', '~> 0.3.2'
gem 'rspec-puppet', '~> 2.0.0'
gem 'rspec-puppet', '~> 2.2.0'
gem 'rspec-puppet-utils', '~> 2.0.0'
gem 'openstack', :require => false
gem 'netaddr'
gem 'deep_merge'
gem 'pry', :require => false
gem 'simplecov', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']

View File

@ -25,9 +25,7 @@ describe manifest do
should_not contain_exec('host-ssh-keygen')
end
end
end
shared_examples 'catalog' do
it 'should declare tools classes' do
should contain_class('osnailyfacter::atop')
should contain_class('osnailyfacter::ssh')

View File

@ -7,6 +7,13 @@ require 'puppetlabs_spec_helper/module_spec_helper'
require 'yaml'
require 'fileutils'
require 'find'
require 'simplecov'
SimpleCov.start do
SimpleCov.coverage_dir("coverage")
SimpleCov.use_merging
SimpleCov.merge_timeout(7200)
end
module Noop
def self.module_path
@ -504,3 +511,10 @@ RSpec.configure do |c|
end
at_exit {
puppet_coverage_report = StringIO.new
$stdout = puppet_coverage_report
RSpec::Puppet::Coverage.report!
File.open("coverage/#{ENV['SPEC_ASTUTE_FILE_NAME']}", 'w') { |file| file.write($stdout.string) }
puts $stdout.string
}