我是writing an R package,正在做下面的皮棉测试:
context("Require no code style errors")
library(lintr)
test_that("Package has no lintr errors", {
lintr::expect_lint_free()
})测试通过了` `devtools::check():
$ Rscript -e "devtools::check()"
...
─ checking tests ...
✔ Running ‘testthat.R’ [61s/65s]
...
0 errors ✔ | 0 warnings ✔ | 0 notes ✔使用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问题是Github和Travis被设置为拒绝未通过测试的拉取请求,并且如果我在devtools::check()之后运行devtools::test(),所有其他测试都会运行两次。
如何让devtools::check()运行lintr测试?
发布于 2019-05-22 18:08:41
这个问题是一个known issue
这不是devtools中的bug (但可能是lintr中的bug)。
devtools::check()在临时目录中运行检查,但lint_package()假设它在包目录中运行,因此没有源文件需要链接。..。您可以用devtools::check(check_dir = ".")来确认这一点,如果devtools::test()这样做了,这应该会产生线条错误。
2015年5月提出的解决方案不再有效。这个问题现在已经被锁定和关闭了,所以它不太可能得到解决。
我建议运行检查并将测试范围缩小到lintr
Rscript -e "devtools::check();devtools::test_file(file = 'testthat/test_lintr.R')"https://stackoverflow.com/questions/56254372
复制相似问题