Improve test coverage functionality #2537
Merged
+40
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was never used correctly because we're passing the path to the package root, instead of the test directory. Additionally, based on https://github.com/hadley/testcoverage, they don't actually appear to be needed.
Fixes r-lib/testthat#1858
@jennybc my main scepticism here for the case of
test_coverage_active_file()
, I can't see how this can possibly work (even though it does). As far as I can tell, nothing intest_coverage_active_file()
causes eitherTESTTHAT_PKG
or the edition to be set correctly, but the tests still pass....
Ooooh maybe the problem is that
test_coverage_active_file()
never actually reveals when the test fails....
Yes, that was the problem, and once I fixed that, it revealed that the snapshot paths weren't set up correctly, and it helped me understand why
local_test_directory()
is needed here, and why it works. I've added comments so hopefully this is less of a journey in the future.