Skip to content

devtools::test() works, but devtools::check() does not for system.file to locate file with .yml extension #2384

@atalv

Description

@atalv

I am trying to locate an external file with .yml extension for creating unit test with testthat while building a R package, the file is placed under \inst folder, as mentioned here https://r-pkgs.org/data.html#data-extdata. Am using system.file() to load the file with yaml package for some unit test (not base::system.file(), so that pkgload:::shim_system.file() can intercept). The tests passes if I do devtools::test(), but it keeps throwing error when I run devtools::check().

However, interestingly after lots of trials I found out that devtools::check() does not throw any error if I save the file with .txt extension instead of .yaml/.yml.

##   inside test_that()
##   cf <- system.file("config", "config1.yml", package = "mypackage", mustWork = TRUE)

##   Error note after devtools::check()
Error in `system.file("config", "config1.yml", package = "mypackage", mustWork = TRUE)`: no file found
Backtrace:
    x
 1. \-base::system.file(...) test-set_config.R:34:2

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 15 ]

# -------------------------------------------------------------

## No error in devtools::check() when config1.yml is renamed as config1.txt !!

Am using latest version of devtools as on CRAN (v2.4.2), on R 4.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions