首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >lintr测试使用devtools::check()通过,使用devtools:: test ()失败

lintr测试使用devtools::check()通过,使用devtools:: test ()失败
EN

Stack Overflow用户
提问于 2019-05-22 18:08:41
回答 1查看 200关注 0票数 0

我是writing an R package,正在做下面的皮棉测试:

代码语言:javascript
复制
context("Require no code style errors")
library(lintr)

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

测试通过了` `devtools::check():

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

使用devtools::test()时,不含棉线的测试失败

代码语言:javascript
复制
$ 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测试?

EN

回答 1

Stack Overflow用户

发布于 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

代码语言:javascript
复制
Rscript -e "devtools::check();devtools::test_file(file = 'testthat/test_lintr.R')"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56254372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档