Skip to content

Commit

Permalink
Don't skip when LC_ALL is unset after all
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Jan 9, 2024
1 parent 5f49227 commit 717aa09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions tests/testthat/helper-pkgload.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ suppress_output <- function(expr) {

# Used to skip tests that will fail when locale is set to C, for
# instance `with_language()` tests. These tests should only be run
# when using a locale like `en_US`. The check is cautious and simple:
# If unset we assume the default might be C or maybe `LANG` is set to C.
# when using a locale like `en_US`.
skip_if_c_locale <- function() {
lc_all <- Sys.getenv("LC_ALL", "")
skip_if(lc_all %in% c("", "C", "C.UTF-8"))
skip_if(lc_all %in% c("C", "C.UTF-8"))

if (lc_all == "") {
lang <- Sys.getenv("LANG", "")
skip_if(lang %in% c("C", "C.UTF-8"))
}
}
6 changes: 3 additions & 3 deletions tests/testthat/test-po.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("translation domain correctly loaded", {
load_all(test_path("testTranslations"))
withr::defer(unload("testTranslations"))

expect_equal(with_language("fr", hello()), "Bonjour")
expect_equal(withr::with_language("fr", hello()), "Bonjour")

load_all(test_path("testTranslations"))
expect_equal(length(temp_po_dirs("testTranslations")), 1)
Expand All @@ -21,7 +21,7 @@ test_that("modified translations are correctly reloaded", {
# Load package and generate translation
load_all(pkg)
withr::defer(unload("testTranslations"))
with_language("fr", hello())
withr::with_language("fr", hello())

# Modify .po file
po_path <- file.path(pkg, "po", "R-fr.po")
Expand All @@ -37,5 +37,5 @@ test_that("modified translations are correctly reloaded", {

# Re-load and re-translate
load_all(pkg)
expect_equal(with_language("fr", hello()), "Salut")
expect_equal(withr::with_language("fr", hello()), "Salut")
})

0 comments on commit 717aa09

Please sign in to comment.