sourcePackageToList
Store Source Packages as Lists and the Inverse.

### Description

Store the files in a source package as an R list and convert that list to a source package. These functions aid in writing test scripts for package installation.

### Usage

    sourcePackageToList(pkgDir)
    listToSourcePackage(List, parentDir = tempfile(fileext = ".dir"))

### Arguments

pkgDir | The name of a directory containing the files comprising a source package. We expect pkgDir to contain files called "DESCRIPTION" and "NAMESPACE" it typically will have directories such as "R", "data", and "src".
List | A named list of NULLs and character vectors. The names represent file paths and should all start with the name of the package. NULL entries represent directories and character entries are the contents of the non-directory files. sourcePackageToList produces such a list from a source package and listToSourcePackage uses such a list to produce a source package.

### Details

These functions help make source packages used to test package installation.
Value
sourcePackageToList returns a list with one entry for each directory or text file in pkgDir, as described above.
listToSourcePackage returns the name of the directory in which the source pacakge was created.
Note
If the source package contains files that contain NULL bytes, illegal UTF-8 byte sequences, a warning will be given that those files will not appear in the list produced by sourcePackageToList. There is one exception: sysdata.rda files will be stored as a non-text attribute to the returned list and listToSourceData will convert that attribute into a sysdata.rda file.
Examples

    L1 <- list(
        "pkg/DESCRIPTION" = c("Package: pkg", "Version: 0.1", "Title: A Package",
                              "Description: A demonstration of listToSourcePackage"),
        "pkg/NAMESPACE" = c("export(increment)"),
        "pkg/R" = NULL, # a directory
        "pkg/R/increment.R" = c("increment <- function(x) x + 1"))
    dir <- assertionTest::listToSourcePackage(L1)
    dir.create(tlib <- tempfile())
    install.packages(repos=NULL, file.path(dir, "pkg"), type = "source", INSTALL_opts = "--no-help", lib=tlib)
    loadNamespace("pkg", lib=tlib)
    all.equal( pkg::increment(c(2,3,5)), c(3,4,6) )
    L2 <- sourcePackageToList(file.path(dir, "pkg"))
    all.equal(L1, L2)

Package assertionTest version 6.1.5-18
Package Index