我testthat用来测试包含类似于以下文件树的包:
.
??? data
? ??? testhaplom.out
??? inst
? ??? test
? ??? test1.r
? ??? tmp_S7byVksGRI6Q
? ? ??? testm.desc
? ??? tmp_vBcIkMN1arbn
? ???testm.bin
? ??? testm.desc
??? R
? ??? haplom.r
? ??? winIdx.r
??? tmp_eUG3Qb0PKuiN
??? testhaplom.hap2.desc
Run Code Online (Sandbox Code Playgroud)
在test1.r文件中,我需要使用该data/testhaplom.out文件作为某个函数的输入数据,但如果我这样做test_file(test1.r),它将更改为inst/test目录并且无法查看数据文件,给出以下错误:
...Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'data/testhaplom.out': No such file or directory
Run Code Online (Sandbox Code Playgroud)