Hi,
Ideally I would subsequently try to hook into the coverage repo and do some post processing looking at where most of the code churn has been in our puppet control code repo and target those areas as important for test coverage (and likely refactoring).
However I've stuck on not being able to get output from simplecov that shows the manifests that were tested by the spec tests, although the summary triggered from running 'RSpec::Puppet::Coverage.report!' suggests that something was capable of tracking coverage correctly.
Although we have a different layout than normal, my testing so far suggests that the reporting simply doesn't work between puppet and simplecov.
Usually when something like this happens, I assume I'm doing something blindingly stupid, so I've put together some example code that shows my problem should anyone like to run through the spec tests from it.
- (HEAD~1 commit): try to follow a more standard layout
- (root commit): Use simple define taken from our codebase and matching the layout we have as closely as possible
Note we're still stuck on Puppet 3.8 and using ruby 2.1.10 via rvm while I was doing the spec tests, plan to
upgrade to 5 in the near future, so if this problem has been solved via
something in the puppet engine (some suggestions that the multiple loading by puppet was wiping SimpleCov's tracking over coverage) and we just need to hurry up that's
great.
But no matter what layout/format I seem to try, the simplecov report prints nothing as having been covered, e.g.:
***************************************************************************************************
Total resources: 9
Touched resources: 8
Resource coverage: 88.89%
Untouched resources:
Ssh::Config_entry[example custom-host]
Finished in 2.01 seconds (files took 1.05 seconds to load)
12 examples, 0 failures
Coverage report generated for RSpec to <path>/puppet-simplecov_bug/html. 0 / 67 LOC (0.0%) covered.
COVERAGE: 0.00% -- 0/67 lines in 2 files
+----------+-------------------------------+-------+--------+-----------------------------------------+
| coverage | file | lines | missed | missing |
+----------+-------------------------------+-------+--------+-----------------------------------------+
| 0.00% | manifests/server/localuser.pp | 67 | 67 | 5-13, 15-19, 21-34, 36-44, 46-55, 57-76 |
+----------+-------------------------------+-------+--------+-----------------------------------------+
1 file(s) with 100% coverage not shown
***************************************************************************************************
RSpec::Puppet::Coverage.report causes the first part to be printed and certainly it shows it's tracking coverage on the files touched, however the simplecov report at the end does not appear to be able to correlate the tests in 'spec/defines/server_localuser_spec.rb' as having tested 'manifests/server/localuser.pp'.
Additionally what is missing from both is all files that are not touched at all so far by tests, though I do have some code that appears to be able to handle that by passing 'track_files("**/*.pp")' to the SimpleCov object configuration.
Rspec::Puppet::Coverage.report! gave:
Total resources: 15
Touched resources: 14
Resource coverage: 93.33%
Untouched resources:
Ssh::Config_entry[example custom-host]
But SimpleCov gave:
Coverage report generated for RSpec to <path>/test-coverage/coverage. 0.0 / 0.0 LOC (100.0%) covered.
So even worse than before...
Resources I've looked at:
my example of the issue:
Hoping that there is something relatively trivial here that I'm missing that allows the reports generated by simplecov to correctly reference spec tests with puppet code.
Regards,
Darragh