knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rcmdcheck

Run R CMD check from R and Capture Results

lifecycle CRAN RStudio mirror downloads R-CMD-check Codecov test coverage

Run R CMD check from R programmatically and capture the results of the individual checks.

Installation

Install the released version from CRAN

install.packages("rcmdcheck")

Or install the development version from GitHub:

# install.packages("pak")
pak::pak("r-lib/rcmdcheck")

Usage

library(rcmdcheck)
rcmdcheck("path/to/R/package")

Call rcmdcheck() on a source R package .tar.gz file, or on a folder containing your R package. Supply quiet = FALSE if you want to omit the output. The result of the check is returned, in a list with elements errors, warnings, and notes. Each element is a character vector, and one element of the character vectors is a single failure.

animated screenshot of a terminal window demonstrating example usage of the rcmdcheck function.

Programmatic usage

rcmdcheck() returns an rcmdcheck object, which you can query and manipulate.

library(rcmdcheck)
chk <- rcmdcheck("tests/testthat/bad1", quiet = TRUE)
chk

check_details() turns the check results into a simple lists with the following information currently:

names(check_details(chk))

Note that if the check results were parsed from a file, some of these fields might be missing (NULL), as we don't have access to the original DESCRIPTION, the installation output, etc.

Parsing check output

parse_check() parses check output from a file, parse_check_url() parses check output from a URL.

CRAN checks

rcmdcheck has a functions to access CRAN's package check results.

cran_check_flavours() downloads the names of the CRAN platforms:

cran_check_flavours()

cran_check_results() loads and parses all check results for a package.

cran_check_results("igraph")

Comparing checks

compare_checks() can compare two or more rcmdcheck objects. compare_to_cran() compares an rcmdcheck object to the CRAN checks of the same package:

chk <- rcmdcheck(quiet = TRUE)
compare_to_cran(chk)

Background processes

rcmdcheck_process is a processx::process class, that can run R CMD check in the background. You can also use this to run multiple checks concurrently. processx::process methods can be used to poll or manipulate the check processes.

chkpx <- rcmdcheck_process$new()
chkpx
chkpx$wait()
chkpx$parse_results()


r-pkgs/rcmdcheck documentation built on Nov. 12, 2023, 2:53 a.m.