-
Notifications
You must be signed in to change notification settings - Fork 27
/
README.Rmd
151 lines (114 loc) · 4.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
title: "Run R CMD check from R and Capture Results"
output:
github_document:
toc: true
toc_depth: 2
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
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
<!-- badges: start -->
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![](https://www.r-pkg.org/badges/version/rcmdcheck)](https://www.r-pkg.org/pkg/rcmdcheck)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/rcmdcheck)](https://www.r-pkg.org/pkg/rcmdcheck)
[![R-CMD-check](https://github.com/r-lib/rcmdcheck/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/rcmdcheck/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/rcmdcheck/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/rcmdcheck?branch=main)
<!-- badges: end -->
Run R CMD check from R programmatically and capture the results of the
individual checks.
## Installation
Install the released version from CRAN
```r
install.packages("rcmdcheck")
```
Or install the development version from GitHub:
```r
# install.packages("pak")
pak::pak("r-lib/rcmdcheck")
```
## Usage
```r
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.
<img width="1000" src="https://cdn.jsdelivr.net/gh/r-lib/rcmdcheck@main/tools/rcmdcheck.svg" alt="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.
```{r}
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:
```{r}
names(check_details(chk))
```
* `package`: Package name.
* `version`: Package version number.
* `notes`: Character vector of check `NOTE`s.
* `warnings`: Character vector of check `WARNING`s.
* `errors`: Character vector of check `ERROR`s.
* `platform`: Platform, e.g. `x86_64-apple-darwin15.6.0`.
* `checkdir`: Check directory.
* `install_out`: Output of the package installation.
* `description`: The text of the `DESCRIPTION` file.
* `session_info`: A `sessioninfo::session_info` object, session information
from within the check process.
* `cran`: Flag, whether this is a CRAN package. (Based on the `Repository`
field in `DESCRIPTION`, which is typically only set for published CRAN
packages.)
* `bioc`: Flag, whether this is a Bioconductor package, based on the
presence of the `biocViews` field in `DESCRIPTION`.
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:
```{r}
cran_check_flavours()
```
`cran_check_results()` loads and parses all check results for a package.
```{r}
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:
```{r}
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.
```{r}
chkpx <- rcmdcheck_process$new()
chkpx
```
```{r}
chkpx$wait()
chkpx$parse_results()
```