Skip to content

Commit

Permalink
fix: pkg srcrefs df building without package objects (#74)
Browse files Browse the repository at this point in the history
* fix: pkg srcrefs df building without package objects
  • Loading branch information
dgkf authored Jan 4, 2024
1 parent d04c692 commit 0c469a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: covtracer
Title: Tools for contextualizing tests
Version: 0.0.0.9014
Version: 0.0.0.9015
Authors@R: c(
person(
given = "Doug",
Expand Down Expand Up @@ -30,7 +30,7 @@ Imports:
Suggests:
testthat,
remotes,
covr (>= 3.5.1.9003),
covr (>= 3.5.2),
withr,
R6,
cli,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased (tentative 0.0.1)

* Fix handling for packages with no objects (#73, @dgkf)

* Add handling for `testthat`'s `describe`-`it` syntax (#63, @dgkf)

* Improve handling of non-function package object aliases (#61, @dgkf)
Expand Down
6 changes: 3 additions & 3 deletions R/srcref_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ pkg_srcrefs_df <- function(x) {
srcs <- pkg_srcrefs(x)
df <- as.data.frame(srcs)
has_srcref <- vapply(df$srcref, inherits, logical(1L), "srcref")
df$namespace <- NA_character_
df[, "namespace"] <- NA_character_

df$namespace[has_srcref] <- vapply(
df[has_srcref, "namespace"] <- vapply(
srcs[has_srcref],
attr,
character(1L),
"namespace"
)

df$namespace[!has_srcref] <- vapply(
df[!has_srcref, "namespace"] <- vapply(
df$name[!has_srcref],
obj_namespace_name,
character(1L),
Expand Down
5 changes: 3 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
get_namespace_object_names <- function(ns) {
out <- getNamespaceExports(ns)
# filter private S4 methods tables and class definitions
out[!grepl("^\\.__(T|C)__", out)]
out[!grepl("^\\.__[TC]__", out)]
}


Expand All @@ -24,7 +24,8 @@ get_namespace_object_names <- function(ns) {
#'
#' @importFrom utils packageVersion
new_empty_test_trace_tally <- function() {
if (utils::packageVersion("covr") < "3.6.3") {
# version needs to be updated until changes are merged
if (utils::packageVersion("covr") <= "3.6.4.9000") {
matrix(
integer(0L),
ncol = 4L,
Expand Down

0 comments on commit 0c469a7

Please sign in to comment.