diff --git a/R/bundlePackage.R b/R/bundlePackage.R index 43857457..5c209359 100644 --- a/R/bundlePackage.R +++ b/R/bundlePackage.R @@ -114,6 +114,6 @@ availablePackages <- function(repos) { } package_record <- function(name, lib_dir = NULL) { - path <- system.file("DESCRIPTION", package = name, lib.loc = lib_dir) - as.list(as.data.frame(read.dcf(path))) + record <- packageDescription(name, lib.loc = lib_dir, encoding = "UTF-8") + unclass(record) } diff --git a/tests/testthat/packages/latin1package/DESCRIPTION b/tests/testthat/packages/latin1package/DESCRIPTION new file mode 100644 index 00000000..1e2278d1 --- /dev/null +++ b/tests/testthat/packages/latin1package/DESCRIPTION @@ -0,0 +1,10 @@ +Package: latin1package +Type: Package +Title: Provides some funky characters. +Version: 0.1.0 +Author: Jens Fr�hling +Maintainer: Jens Fr�hling +Description: a test package +License: GPL-2 +Encoding: latin1 +LazyData: true diff --git a/tests/testthat/packages/latin1package/NAMESPACE b/tests/testthat/packages/latin1package/NAMESPACE new file mode 100644 index 00000000..d75f824e --- /dev/null +++ b/tests/testthat/packages/latin1package/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/tests/testthat/packages/latin1package/R/hello.R b/tests/testthat/packages/latin1package/R/hello.R new file mode 100644 index 00000000..97d59e2c --- /dev/null +++ b/tests/testthat/packages/latin1package/R/hello.R @@ -0,0 +1,3 @@ +hello <- function() { + print("Hello, world!") +} diff --git a/tests/testthat/packages/latin1package/man/hello.Rd b/tests/testthat/packages/latin1package/man/hello.Rd new file mode 100644 index 00000000..0fa7c4b8 --- /dev/null +++ b/tests/testthat/packages/latin1package/man/hello.Rd @@ -0,0 +1,12 @@ +\name{hello} +\alias{hello} +\title{Hello, World!} +\usage{ +hello() +} +\description{ +Prints 'Hello, world!'. +} +\examples{ +hello() +} diff --git a/tests/testthat/packages/utf8package/DESCRIPTION b/tests/testthat/packages/utf8package/DESCRIPTION new file mode 100644 index 00000000..ef4ab6dd --- /dev/null +++ b/tests/testthat/packages/utf8package/DESCRIPTION @@ -0,0 +1,10 @@ +Package: utf8package +Type: Package +Title: Provides some funky characters. +Version: 0.1.0 +Author: Jens Fröhling +Maintainer: Jens Fröhling +Description: a test package +License: GPL-2 +Encoding: UTF-8 +LazyData: true diff --git a/tests/testthat/packages/utf8package/NAMESPACE b/tests/testthat/packages/utf8package/NAMESPACE new file mode 100644 index 00000000..d75f824e --- /dev/null +++ b/tests/testthat/packages/utf8package/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/tests/testthat/packages/utf8package/R/hello.R b/tests/testthat/packages/utf8package/R/hello.R new file mode 100644 index 00000000..97d59e2c --- /dev/null +++ b/tests/testthat/packages/utf8package/R/hello.R @@ -0,0 +1,3 @@ +hello <- function() { + print("Hello, world!") +} diff --git a/tests/testthat/packages/utf8package/man/hello.Rd b/tests/testthat/packages/utf8package/man/hello.Rd new file mode 100644 index 00000000..0fa7c4b8 --- /dev/null +++ b/tests/testthat/packages/utf8package/man/hello.Rd @@ -0,0 +1,12 @@ +\name{hello} +\alias{hello} +\title{Hello, World!} +\usage{ +hello() +} +\description{ +Prints 'Hello, world!'. +} +\examples{ +hello() +} diff --git a/tests/testthat/packages/windows1251package/DESCRIPTION b/tests/testthat/packages/windows1251package/DESCRIPTION new file mode 100644 index 00000000..b6b3414f --- /dev/null +++ b/tests/testthat/packages/windows1251package/DESCRIPTION @@ -0,0 +1,10 @@ +Package: windows1251package +Type: Package +Title: Provides some funky characters. +Version: 0.1.0 +Author: ������ ���� +Maintainer: ������ ���� +Description: a test package +License: GPL-2 +Encoding: Windows-1251 +LazyData: true diff --git a/tests/testthat/packages/windows1251package/NAMESPACE b/tests/testthat/packages/windows1251package/NAMESPACE new file mode 100644 index 00000000..d75f824e --- /dev/null +++ b/tests/testthat/packages/windows1251package/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/tests/testthat/packages/windows1251package/R/hello.R b/tests/testthat/packages/windows1251package/R/hello.R new file mode 100644 index 00000000..97d59e2c --- /dev/null +++ b/tests/testthat/packages/windows1251package/R/hello.R @@ -0,0 +1,3 @@ +hello <- function() { + print("Hello, world!") +} diff --git a/tests/testthat/packages/windows1251package/man/hello.Rd b/tests/testthat/packages/windows1251package/man/hello.Rd new file mode 100644 index 00000000..0fa7c4b8 --- /dev/null +++ b/tests/testthat/packages/windows1251package/man/hello.Rd @@ -0,0 +1,12 @@ +\name{hello} +\alias{hello} +\title{Hello, World!} +\usage{ +hello() +} +\description{ +Prints 'Hello, world!'. +} +\examples{ +hello() +} diff --git a/tests/testthat/test-bundlePackage.R b/tests/testthat/test-bundlePackage.R index bf0520cb..140bc1e7 100644 --- a/tests/testthat/test-bundlePackage.R +++ b/tests/testthat/test-bundlePackage.R @@ -133,3 +133,14 @@ test_that("usePackrat prefers the environment variable over the option", { withr::local_options(rsconnect.packrat = TRUE) expect_false(usePackrat()) }) + +test_that("package_record works", { + latin1Record <- package_record("latin1package", lib_dir = test_path("packages")) + expect_equal(latin1Record$Author, "Jens Fröhling") + + utf8Record <- package_record("utf8package", lib_dir = test_path("packages")) + expect_equal(utf8Record$Author, "Jens Fröhling") + + windows1251Record <- package_record("windows1251package", lib_dir = test_path("packages")) + expect_equal(windows1251Record$Author, "Сергей Брин") +})