I perform a major edit since I managed to narrow down the problem:
I encounter a new problem with devtools::test. My package used to pass unit test without any problem. But after updating my packages (including devtools and testthat) it now fails.
Reproducible example:
I have managed to build a reproducible example: In a new package architecture.
foo.R: a R file in /R/
foo <- function(obj){
return(as.numeric(obj))
}
test_foo.R: a uniit test file in /tests/testthat
test_that("Test my foo function: ",
{
expect_true(is.na(foo("1,5")))
})
testhat.R: to run my units tests in /tests/
library(testthat)
library(foo)
test_check("foo")
Two scenarios
Running: devtools::test()
> devtools::test()
Loading foo
Loading required package: testthat
Testing foo
√ | OK F W S | Context
Error in x[[method]](...) : attempt to apply non-function
== Results =====================================================================
Duration: 0.1 s
OK: 0
Failed: 4
Warnings: 1
Skipped: 0
Running testtjat::test_dir("tests/")
> testthat::test_dir("tests/")
√ | OK F W S | Context
== testthat results ===========================================================
OK: 2 SKIPPED: 0 FAILED: 0
== Results =====================================================================
Duration: 0.1 s
OK: 0
Failed: 0
Warnings: 0
Skipped: 0
Environement
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] foo_0.0.0.9000 testthat_2.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 roxygen2_6.0.1 rprojroot_1.3-2 crayon_1.3.4 assertthat_0.2.0 digest_0.6.14 withr_2.1.1 commonmark_1.4
[9] R6_2.2.2 backports_1.1.2 magrittr_1.5 cli_1.0.0 rlang_0.1.6 stringi_1.1.6 rstudioapi_0.7 xml2_1.1.1
[17] desc_1.1.1 devtools_1.13.4 tools_3.4.3 stringr_1.2.0 yaml_2.1.16 compiler_3.4.3 memoise_1.1.0
NB:
An issue have been open on this matter on Github: https://github.com/hadley/devtools/issues/1675