【发布时间】:2018-02-02 23:39:09
【问题描述】:
我正在构建一个 R 包,RE,我想用它打包一个独立的脚本,放在 RE/exec/wrapper.R 中。我为 testthat 编写了一个测试函数,它在使用devtools::test("RE") 从命令行运行时运行良好,但在使用devtools::check("RE") 运行时失败。
失败的相关代码部分是:
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 的问题。
【问题讨论】: