r-hyperspec / hyperSpec

hyperSpec: Tools for Spectroscopy (R package)
https://r-hyperspec.github.io/hyperSpec/
GNU General Public License v3.0
12 stars 3 forks source link

unit tests failing with LANGUAGE different than English #26

Closed cbeleites closed 3 years ago

cbeleites commented 3 years ago

A number of unit tests fail if the LANGUAGE environment variable is other than English.

GegznaV commented 3 years ago

Originally I wrote this as my comment in #27 but, I think, here is a better place for discussions.


Wouldn't it be easier to use testthat edition 3, which automatically sets the language to English:

In https://www.tidyverse.org/blog/2020/10/testthat-3-0-0/:

test_that() now sets a number of options and env vars to make output as reproducible as possible. Many of these options were previously set in various places (including devtools::test(), test_dir(), test_file(), and verify_output()) but they have now been centralised in to local_test_context().

In the Details section of local_test_context() documentation:

In the third edition, local_test_context() also calls local_reproducible_output() which temporary sets the following options:

...

And modifies the following env vars:

  • Unsets RSTUDIO, which ensures that RStudio is never detected as running.
  • Sets LANGUAGE = "en", which ensures that no message translation occurs.

Finally, it sets the collation locale to "C", which ensures that character sorting the same regardless of system locale.

So I suggest trying testthat edition 3. If it fails, then considering merging this PR.

Is it OK with you, @cbeleites?

cbeleites commented 3 years ago

That's fine with me. Though we need to consider a few more things: e.g. edition 3 h has context() deprecated - which we very much rely on with hySpc.testthat. The more I think about this, the more I think that @bryanhanson's roxut package is a much better solution than hySpc.testthat.