Skip to content

Commit

Permalink
use devtools::inst() to make sure we always modify the **installed** …
Browse files Browse the repository at this point in the history
…version of the package, and add a test using load_all() followed by install as this was causing a failure previously
  • Loading branch information
rmflight committed Jan 21, 2016
1 parent cbb090e commit 1c3fccd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/install.r
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ install <- function(pkg = ".", reload = TRUE, quick = FALSE, local = TRUE,
quiet = quiet)

if (length(metadata) > 0) {
add_metadata(base::find.package(pkg$package), metadata)
add_metadata(inst(pkg$package), metadata)
}

if (reload) {
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-remote-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ test_that("install on packages adds metadata", {
pkg_source <- pkg_info[pkg_info[, "package"] %in% "testMetadataInstall", "source"]
expect_match(pkg_source, "local")

# use load_all() and reinstall
git2r::add(r, file.path(test_pkg, "test.txt"))
git2r::commit(r, "adding test.txt")
load_all(test_pkg, quiet = TRUE)
install(test_pkg, quiet = TRUE)
pkg_info <- session_info()$packages
pkg_source <- pkg_info[pkg_info[, "package"] %in% "testMetadataInstall", "source"]
pkg_sha <- substring(git2r::commits(r)[[1]]@sha, 1, 7)
expect_match(pkg_source, pkg_sha)

})

0 comments on commit 1c3fccd

Please sign in to comment.