Skip to content

Commit cccf084

Browse files
authored
Merge pull request #7 from kforner/fixing_for_devtools_2.5
Fixing for devtools 2.5
2 parents 8fbbc36 + 631dd1a commit cccf084

22 files changed

Lines changed: 44 additions & 53 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Description: Manage a collection/library of R source packages. Discover, documen
99
License: GPL (>= 3)
1010
Encoding: UTF-8
1111
Roxygen: list(markdown = TRUE)
12-
RoxygenNote: 7.3.2
12+
RoxygenNote: 7.3.3
1313
URL: https://github.com/kforner/srcpkgs
1414
BugReports: https://github.com/kforner/srcpkgs/issues
1515
Imports:

R/pkg_check.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ as.data.frame.pkg_check <- function(x, ...) {
3333
#' @param ... passed to `devtools::check()`
3434
#' @return the results as a `pkg_test` object, or NULL if no tests found
3535
#' @export
36-
#' @examples
37-
#' \donttest{
38-
#' pkg <- setup_and_get_dummy_srcpkg()
39-
#' res <- pkg_check(pkg, lib = tempfile(), error_on = "never")
40-
#' print(res)
41-
#' }
4236
pkg_check <- function(pkgid, src_pkgs = get_srcpkgs(), lib = ".check", roxygen = TRUE,
4337
quiet = FALSE, error_on = "error", check_system_clock = FALSE, ...)
4438
{

R/pkg_load.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#' @return the load plan as a data frame, or NULL if there is nothing to do.
2828
#' @export
2929
#' @examples
30-
#' pkg <- setup_and_get_dummy_srcpkg()
30+
#' root <- tempfile()
31+
#' pkg <- setup_and_get_dummy_srcpkg(root)
32+
#' reset(root)
3133
#' # load and attach a package
3234
#' pkg_load(pkg)
3335
#'

R/pkg_meta.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
# fetches meta data about loaded source packages as a data frame, or NULL if no info
66
# N.B: use the devtools meta data, and stores the package hash inside it
77
fetch_srcpkgs_meta <- function() {
8-
pkgs_names <- sort(devtools::dev_packages())
8+
pkgs_names <- sort(dev_packages_fixed())
99
pkgs <- lapply(pkgs_names, fetch_srcpkg_meta)
1010
pkgs <- pkgs[lengths(pkgs) > 0] %||% return(NULL)
1111
pkgs <- srcpkgs(pkgs)
12-
12+
1313
df <- as.data.frame(pkgs)
1414

1515
df$attached <- !is.na(match(rownames(df), sub('package:', '', search())))
1616

1717
df
1818
}
1919

20+
# devtools::dev_packages() does not work any longer in devtools >= 2.5
21+
dev_packages_fixed <- function() {
22+
loaded <- loadedNamespaces()
23+
have_meta <- sapply(loaded, function(x) !is.null(pkgload::dev_meta(x)))
24+
loaded[have_meta]
25+
}
2026

2127
get_or_set_meta <- function(meta_env, value) {
2228
key <- 'SRCPKGS_META_KEY'

R/pkg_test.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#' @importFrom testthat test_dir
1313
#' @export
1414
#' @examples
15-
#' pkg <- setup_and_get_dummy_srcpkg()
15+
#' root <- tempfile()
16+
#' pkg <- setup_and_get_dummy_srcpkg(root)
17+
#' reset(root)
1618
#' res <- pkg_test(pkg)
1719
#' print(res)
1820
pkg_test <- function(pkgid, filter = NULL, src_pkgs = get_srcpkgs(), export_all = TRUE, quiet = TRUE, ...)

R/pkg_unload.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#' attached, invisibly or NULL if the package is not loaded
1212
#' @export
1313
#' @examples
14-
#' pkg <- setup_and_get_dummy_srcpkg()
14+
#' root <- tempfile()
15+
#' pkg <- setup_and_get_dummy_srcpkg(root)
16+
#' reset(root)
1517
#' pkg_load(pkg)
1618
#'
1719
#' pkg_unload(pkg)

R/pkgs_check.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ summary.pkgs_check <- function(object, ...) {
5858
#' @param ... passed to `pkg_check`
5959
#' @return the results as a `pkgs_test` object
6060
#' @export
61-
#' @examples
62-
#' \donttest{
63-
#' pkg <- setup_and_get_dummy_srcpkg()
64-
#' res <- pkgs_check(pkg, lib = tempfile(), fail_on_error = FALSE)
65-
#' print(res)
66-
#' }
6761
pkgs_check <- function(pkgids = names(filter_srcpkgs(src_pkgs, filter)), src_pkgs = get_srcpkgs(),
6862
filter = NULL, lib = ".check", quiet = FALSE, fail_on_error = FALSE, ...)
6963
{

R/pkgs_install.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#' @param ... passed to `devtools::install()`
1010
#' @return the names of the packages actually installed
1111
#' @export
12-
#' @examples
13-
#' pkg <- setup_and_get_dummy_srcpkg()
14-
#' dest <- tempfile()
15-
#' pkgs_install(pkg, dest)
1612
pkgs_install <- function(pkgids, lib, src_pkgs = get_srcpkgs(), only_deps = FALSE, quiet = TRUE, ...)
1713
{
1814
stop_unless(length(pkgids), "No package to test")
@@ -29,7 +25,8 @@ pkgs_install <- function(pkgids, lib, src_pkgs = get_srcpkgs(), only_deps = FALS
2925
pkg <- src_pkgs[[pkg_name]]
3026

3127
# is_loaded <- pkg_is_loaded(pkg_name)
32-
pkg_roxygenise(pkg$path, quiet = quiet)
28+
# pkg_roxygenise(pkg$path, quiet = quiet)
29+
pkg_load(pkg, src_pkgs, attach = FALSE, roxygen = TRUE, quiet = quiet)
3330
# if (!is_loaded) unloadNamespace(pkg_name)
3431

3532
if (!pkg_needs_install(pkg$path, lib)) return(NULL)

dev.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ test(filter = "graph")
99
test(filter = "examples")
1010
test(filter = "pkg_check")
1111
test(filter = "pkg_load")
12+
test(filter = "pkg_meta")
1213
test(filter = "pkg_test")
1314
test(filter = "pkg_utils")
1415
test(filter = "pkgs_check")
1516
test(filter = "pkgs_deps")
17+
test(filter = "pkgs_install")
1618
test(filter = "pkgs_test")
1719
test(filter = "project_root")
1820
test(filter = "srcpkg$")
@@ -30,5 +32,7 @@ system.time(withr::with_dir("vignettes", rmarkdown::render("demo.Rmd")))
3032
build_vignettes()
3133
run_examples()
3234
run_examples(run_donttest = TRUE)
35+
run_examples(start = "pkgs_install")
36+
3337

3438
rhub::rhub_check(platforms="windows")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
test_that("does_nothing_special - failure", {
3-
expect_equal(does_nothing_special(), 0)
3+
expect_equal(dummy.srcpkg:::does_nothing_special(), 0)
44
})
55

0 commit comments

Comments
 (0)