Sto usando testthat
di testare un pacchetto con un albero di file simile al seguente:R - testthat utilizzando file di dati al di fuori della directory test
.
├── 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
Nel file test1.r
, ho bisogno di utilizzare il file data/testhaplom.out
come dati di input per una certa funzione, ma se lo faccio test_file(test1.r)
, cambia nella directory inst/test
e non può vedere il file di dati, dando il seguente errore:
...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