Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible improvement for tools::testInstalledPackage #89

Open
llrs opened this issue Apr 30, 2024 · 0 comments
Open

Possible improvement for tools::testInstalledPackage #89

llrs opened this issue Apr 30, 2024 · 0 comments
Labels
R About R itself

Comments

@llrs
Copy link
Owner

llrs commented Apr 30, 2024

See r-lib/covr#548 (comment)

Copied from there:

This probably could be a bug to the tools package, but it is easy enough to fix here.

The tools bug is that when install_path is a relative path tools::testInstalledPackages has a failure when type="examples" and silently ignores all tests when type="tests".

path <- normalizePath(".")
package <- basename(path)
install_path <- "../temp_install_path"
out_dir <- file.path(install_path, package)

dir.create(install_path)
utils::install.packages(repos = NULL,
                        lib = install_path,
                        path,
                        type = "source",
                        INSTALL_opts = c("--example",
                                         "--install-tests",
                                         "--with-keep.source",
                                         "--with-keep.parse.data",
                                         "--no-staged-install",
                                         "--no-multiarch"),
                        quiet = FALSE)



# Fails (when both out_dir is set & install_path is set to a relative path)
tools::testInstalledPackage(package, outDir = out_dir, types = "examples", lib.loc = install_path)
#> Testing examples for package ‘covr’
#> Error in find.package(package, lib.loc) : 
#>   there is no package called ‘covr’

# Silently doesn't run any tests
tools::testInstalledPackage(package, outDir = out_dir, types = "tests", lib.loc = install_path)



# Need to normalize the install_path
normalized_install_path <- normalizePath(install_path)

# Works
tools::testInstalledPackage(package, outDir = out_dir, types = "examples", lib.loc = normalized_install_path)

# Works
tools::testInstalledPackage(package, outDir = out_dir, types = "tests", lib.loc = normalized_install_path)
@llrs llrs added the R About R itself label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R About R itself
Projects
None yet
Development

No branches or pull requests

1 participant