I would like to run the package-internal tests with testthat::test_package('httr')
on a specific version of a package.
Is there a way to install a R package (e.g. from CRAN) with a specific version AND it's tests?
I know there is
install.packages("httr", INSTALL_opts = "--install-tests")
to install the tests for the given package (without any option to specify a specific package version).
And there is
devtools::install_version("httr", version = "1.4.1")
or renv::install("httr@1.4.1")
to install a specific version for a package (without the possibility to specify e.g. the INSTALL_opts).
I don't see any way to combine the specification of the package version and the --install-tests
option.
Any help would be appreciated!
Note: The package "httr" was just used as a placeholder here.
renv
provides a small extension where these options can be set via the INSTALL_opts
R option. So, for example, the following should work with renv 0.14.0
:
# set options for renv
options(INSTALL_opts.httr = "--install-tests")
# use 'rebuild = true', in case an older version
# of the package without tests is cached
renv::install("httr@1.4.1", rebuild = TRUE)
If you wanted these options to apply to all package to be installed, you could instead use:
options(INSTALL_opts = "--install-tests")
(renv
supports setting these via options mainly so that package installation via renv::restore()
can be configured more ergonomically on a per-package basis.)