I am trying to address:
Warning message:
"encoding is deprecated; all files now assumed to be UTF-8"
as produced by testthat functions test-directory and source for package GGIR.
I only get this warning message when testing the package as a whole, and not when running the individual tests with test_file().
What did NOT help was:
options(encoding = "UTF-8") to the top of each test file one line below library(mypackagename).options(encoding = "UTF-8") to testthat.R one line below library(mypackagename).fileEncoding="UTF-8" to all my calls to write.table.Could it be that the warning message is printed regardless of whether I use UTF-8 encoding or not and that I am trying to fix an issue that does not really exist? If yes, should the warning message then be a note rather than an warning? If not, could you advise me on what might cause this warning message and how to address it?
thanks, Vincent (and thanks for the great package!)
My sessionInfo():
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=nl_NL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=nl_NL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] testthat_2.0.0 GGIR_1.5-22
loaded via a namespace (and not attached):
[1] compiler_3.4.4 magrittr_1.5 R6_2.2.2 tools_3.4.4 yaml_2.1.18 Rcpp_0.12.16
[7] data.table_1.10.4-3 rlang_0.2.0
I believe the problem is in devtools::test, which does this:
testthat_args <- c(testthat_args, load_helpers = FALSE,
encoding = pkg$encoding %||% "unknown")
That makes sure encoding is always set, even though it's now a deprecated arg. When testthat::test_dir is called with those args, it does this:
if (!missing(encoding) && !identical(encoding, "UTF-8")) {
warning("`encoding` is deprecated; all files now assumed to be UTF-8",
call. = FALSE)
}
which produces the warning.
A fix would be to only add the encoding arg if testthat is less than some particular version.
Took a crack at this issue in Pull Request #767. Went about a solution a little different than your suggestion, @kenahoo. Curious to hear feedback.
Fixed in devtools.
Most helpful comment
I believe the problem is in
devtools::test, which does this:That makes sure
encodingis always set, even though it's now a deprecated arg. Whentestthat::test_diris called with those args, it does this:which produces the warning.
A fix would be to only add the
encodingarg iftestthatis less than some particular version.