testInstalledPackage {tools} | R Documentation |
Test Installed Packages
Description
These functions allow an installed package to be tested, or all base and recommended packages.
Usage
testInstalledPackage(pkg, lib.loc = NULL, outDir = ".",
types = c("examples", "tests", "vignettes"),
srcdir = NULL, Ropts = "", ...)
testInstalledPackages(outDir = ".", errorsAreFatal = TRUE,
scope = c("both", "base", "recommended"),
types = c("examples", "tests", "vignettes"),
srcdir = NULL, Ropts = "", ...)
testInstalledBasic(scope = c("basic", "devel", "both", "internet", "all"),
outDir = file.path(R.home(), "tests"),
testSrcdir = getTestSrcdir(outDir))
standard_package_names()
Arguments
pkg |
name of an installed package. |
lib.loc |
library path(s) in which to look for the package. See
|
outDir |
the directory into which to write the output files: this
should already exist. The default, |
types |
type(s) of tests to be done. |
srcdir |
Optional directory to look for |
Ropts |
Additional options such as -d valgrind to be
passed to |
errorsAreFatal |
logical: should testing terminate at the first error? |
scope |
a string indicating which set(s) should be tested.
|
... |
additional arguments use when preparing the files to be
run, e.g. |
testSrcdir |
optional directory where the test R scripts are found. |
Details
The testInstalledPackage{s}()
tests depend on having the package
example files installed (which is the default).
If package-specific tests are found in a
‘tests’ directory they can be tested: these are not
installed by default, but will be if
R CMD INSTALL --install-tests
was used. Finally, the R
code in any vignettes can be extracted and tested.
The package-specific tests are run in a ‘pkg-tests’ subdirectory of
‘outDir’, and leave their output there.
testInstalledBasic
runs the basic tests, if installed or inside
testSrcdir
. This
should be run with LC_COLLATE set to ‘C’:
the function tries to set
this but it may not work on all OSes. For non-English locales it may
be desirable to set environment variables LANGUAGE to ‘en’
and LC_TIME to ‘C’ to reduce the number of differences from
reference results.
Except on Windows, if the environment variable TEST_MC_CORES is
set to an integer greater than one, testInstalledPackages
will
run the package tests in parallel using its value as the maximum
number of parallel processes.
The package-specific tests for the base and recommended packages are
an optional part of the install, where on unix-alikes, i.e., not on Windows,
make install-tests
is provided to do so (as well as the basic tests).
On Windows, currently testing requires a Unix-like diff
for a
full report if more than simple differences are found.
Value
Invisibly 0L
for success, 1L
for failure.
standard_package_names()
returns a list
with
components named
base |
a |
recommended |
a |
Examples
str(stPkgs <- standard_package_names())
## consistency of packageDescription and standard_package_names :
(pNms <- unlist(stPkgs, FALSE))
(prio <- sapply(as.vector(pNms), packageDescription, fields = "Priority"))
stopifnot(identical(unname(prio),
sub("[0-9]+$", '', names(pNms))))