mercredi 22 mai 2019

lintr test passes with devtools::check() and fails with devtools::test()

I am writing an R package with the following lint test:

context("Require no code style errors")
library(lintr)

test_that("Package has no lintr errors", {
    lintr::expect_lint_free()
})

The tests pass with `devtools::check():

$ Rscript -e "devtools::check()"
...
─  checking tests ...
✔  Running ‘testthat.R’ [61s/65s]
...
0 errors ✔ | 0 warnings ✔ | 0 notes ✔

and the lint-free test fails with devtools::test():

$ Rscript -e "devtools::test()"
...
Testing PosteriorBootstrap
...
✖ |  0 1     | Require no code style errors [6.2 s]
────────────────────────────────────────────────────────────────────────────────
test_lintr.R:5: failure: Package has no lintr errors
Not lint free
tests/testthat/test_anpl.R:112:1: style: Trailing whitespace is superfluous.

^~
...
OK:       20
Failed:   1
Warnings: 0
Skipped:  0

The problem is that Github and Travis are set to reject pull requests that fail the tests, and that if I run devtools::test() after devtools::check(), all the other tests run twice.

How can I get devtools::check() to run the lintr test?

Aucun commentaire:

Enregistrer un commentaire