0
我正在构建一个R软件包RE
,我想打包一个独立脚本并将其放在RE/exec/wrapper.R中。我已经为测试编写了一个测试函数,它在使用devtools::test("RE")
从命令行运行时工作得很好,但在使用devtools::check("RE")
运行时失败。如何使用testthat测试作为软件包一部分的独立R脚本
相关的代码部分:
cmd <- "Rscript \"C:\\RE\\exec\\wrapper.R\" base print \"{\\\"x\\\": 2}\""
rv <- system(cmd, intern = FALSE, ignore.stderr = FALSE, show.output.on.console = FALSE)
当为“测试”部分运行一切都正常运行和system
回报0
,因为它应该。当作为“检查”的一部分运行时,system
会给出下面给出的错误消息并返回1
。
Error in file(filename, "r", encoding = encoding) : cannot open the connection
Calls: local ... eval.parent -> eval -> eval -> eval -> eval -> source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) : cannot open file 'startup.Rs': No such file or directory
Execution halted
我:
- 选中该文件存在(它在这两种情况下)
- 试过
tryCatch
。没有错误被发现,并system
刚刚返回1
这让我觉得,这是system
和R CMD CHECK
的问题。