diff --git a/CRAN_Release.cmd b/CRAN_Release.cmd index 649c86a446..9b5c9b4357 100644 --- a/CRAN_Release.cmd +++ b/CRAN_Release.cmd @@ -121,6 +121,11 @@ q("no") R CMD check data.table_1.12.3.tar.gz rm ~/.Renviron +# Test non-English does not break test.data.table() due to translation of messages; #3039, #630 +LANGUAGE=de R +require(data.table) +test.data.table() + R remove.packages("xml2") # we checked the URLs; don't need to do it again (many minutes) require(data.table) diff --git a/NEWS.md b/NEWS.md index ca415e1689..719c9b52dc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -102,6 +102,8 @@ 10. `externalVar=1:5; DT[, mean(externalVar), by=group]` could return incorrect results rather than a constant (`3` in this example) for each group, [#875](https://github.com/Rdatatable/data.table/issues/875). GForce optimization was being applied incorrectly to the `mean` without realizing `externalVar` was not a column. +11. `test.data.table()` now passes in non-English R sessions, [#630](https://github.com/Rdatatable/data.table/issues/630) [#3039](https://github.com/Rdatatable/data.table/issues/3039). Each test still checks that the number of warnings and/or errors produced is correct. However, a message is displayed suggesting to restart R with `LANGUAGE=en` in order to test that the text of the warning and/or error messages are as expected, too. + #### NOTES 1. `rbindlist`'s `use.names="check"` now emits its message for automatic column names (`"V[0-9]+"`) too, [#3484](https://github.com/Rdatatable/data.table/pull/3484). See news item 5 of v1.12.2 below. diff --git a/R/test.data.table.R b/R/test.data.table.R index 8a9b2fc298..7f161b3bdc 100644 --- a/R/test.data.table.R +++ b/R/test.data.table.R @@ -60,6 +60,17 @@ test.data.table <- function(verbose=FALSE, pkg="pkg", silent=FALSE, with.other.p cat("Running", fn, "\n") env = new.env(parent=.GlobalEnv) assign("testDir", function(x) file.path(fulldir, x), envir=env) + + # are R's messages being translated to a foreign language? #3039, #630 + txt = eval(parse(text="tryCatch(mean(not__exist__), error = function(e) e$message)"), envir=.GlobalEnv) + foreign = txt != "object 'not__exist__' not found" + if (foreign) { + # nocov start + cat("\n**** This R session's language is not English. Each test will still check that the correct number of errors and/or\n", + "**** warnings are produced. However, to test the text of each error/warning too, please restart R with LANGUAGE=en\n\n", sep="") + # nocov end + } + assign("foreign", foreign, envir=env) assign("nfail", 0L, envir=env) assign("ntest", 0L, envir=env) assign("prevtest", -1, envir=env) @@ -221,6 +232,7 @@ test <- function(num,x,y=TRUE,error=NULL,warning=NULL,output=NULL,message=NULL) memtest = get("memtest", parent.frame()) inittime = get("inittime", parent.frame()) filename = get("filename", parent.frame()) + foreign = get("foreign", parent.frame()) time = nTest = NULL # to avoid 'no visible binding' note on.exit( { now = proc.time()[3] @@ -300,7 +312,7 @@ test <- function(num,x,y=TRUE,error=NULL,warning=NULL,output=NULL,message=NULL) } else { # the expected type occurred and, if more than 1 of that type, in the expected order for (i in seq_along(expected)) { - if (!string_match(expected[i], observed[i])) { + if (!foreign && !string_match(expected[i], observed[i])) { # nocov start cat("Test",numStr,"didn't produce the correct",type,":\n") cat("Expected:", expected[i], "\n")