testInstalledPackage {tools}R Documentation

Test Installed Packages


These functions allow an installed package to be tested, or all base and recommended packages.


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"))



name of an installed package.


library path(s) in which to look for the package. See library.


the directory into which to write the output files: this should already exist.


type(s) of tests to be done.


logical: should testing terminate at the first error?


Optional directory to look for .save files.


Additional options such as -d valgrind to be passed to R CMD BATCH when running examples or tests.


additional arguments use when preparing the files to be run, e.g. commentDontrun and commentDonttest.


Which set(s) should be tested? Can be abbreviated.


These 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.

Package tests are run in a ‘pkg-tests’ subdirectory of ‘outDir’, and leave their output there.

testInstalledBasic runs the basic tests, if installed. This should be run with LC_COLLATE=C set: the function tries to set this by 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 not normally installed, but make install-tests is provided to do so (as well as the basic tests).


Invisibly 0L for success, 1L for failure.

[Package tools version 3.6.0 Index]