Skip to content

Commit

Permalink
Have test_coverage_file work without a 1 to 1 correspondence
Browse files Browse the repository at this point in the history
Fixes #2011
  • Loading branch information
jimhester committed Sep 5, 2019
1 parent 54532ce commit 80f0e9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# devtools (development version)

* `test_coverage_file()` now works when there is not a 1 to 1 correspondence
between test and source files (#2011).

* New `dev_sitrep()` function to return information about your development
environment and diagnose common problems. The former functions
`dr_devtools()` and `dr_github()` have been deprecated. (#1970)
Expand Down
8 changes: 7 additions & 1 deletion R/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ test_coverage_file <- function(file = find_active_file(), filter = TRUE, show_re
})
)

filter <- isTRUE(filter) && all(file.exists(source_files))

if (isTRUE(filter)) {
coverage <- coverage[covr::display_name(coverage) %in% source_files]
}
Expand All @@ -273,7 +275,11 @@ test_coverage_file <- function(file = find_active_file(), filter = TRUE, show_re
attr(coverage, "package") <- pkg

if (isTRUE(show_report)) {
covr::file_report(coverage)
if (isTRUE(filter)) {
covr::file_report(coverage)
} else {
covr::report(coverage)
}
}

invisible(coverage)
Expand Down

0 comments on commit 80f0e9c

Please # to comment.