Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.5.1 #232

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: withr
Title: Run Code 'With' Temporarily Modified Global State
Version: 2.5.0
Version: 2.5.1
Authors@R:
c(person(given = "Jim",
family = "Hester",
role = "aut"),
person(given = "Lionel",
family = "Henry",
role = c("aut", "cre"),
email = "lionel@rstudio.com"),
email = "lionel@posit.co"),
person(given = "Kirill",
family = "Müller",
role = "aut",
Expand All @@ -30,7 +30,7 @@ Authors@R:
person(given = "Richard",
family = "Cotton",
role = "ctb"),
person(given = "RStudio",
person(given = "Posit Software, PBC",
role = c("cph", "fnd")))
Description: A set of functions to run code 'with' safely and
temporarily modified global state. Many of these functions were
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# withr 2.5.1

* Fixes for CRAN checks.


# withr 2.5.0

* `defer()` and all `local_*()` functions now work when run inside of
Expand Down
4 changes: 2 additions & 2 deletions R/timezone.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @examples
#' Sys.time()
#' with_timezone("Europe/Paris", print(Sys.time()))
#' with_timezone("US/Pacific", print(Sys.time()))
#' with_timezone("America/Los_Angeles", print(Sys.time()))
#'
with_timezone <- function(tz, code) {
reset_timezone()
Expand All @@ -34,7 +34,7 @@ with_timezone <- function(tz, code) {
#' }
#'
#' fun2 <- function() {
#' local_timezone("US/Pacific")
#' local_timezone("America/Los_Angeles")
#' print(Sys.time())
#' }
#' Sys.time()
Expand Down
10 changes: 1 addition & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
## R CMD check results
There were no NOTEs, ERRORs or WARNINGs.

## revdepcheck results

We checked 324 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
Fixes the timezone and translation issues
4 changes: 2 additions & 2 deletions man/with_tempfile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/with_timezone.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ skip_if_cannot_knit <- function() {
skip_if_not_installed("rmarkdown")
skip_if(!rmarkdown::pandoc_available())
}

# Need to also specify `LC_ALL` because `LANGUAGE` is ignored when
# `LANG` is set (here via `LC_ALL`) to `C` or `C.UTF-8`
with_lang <- function(lc, language, expr) {
withr::local_envvar(c(LC_ALL = lc))
withr::local_language(language)
expr
}
10 changes: 5 additions & 5 deletions tests/testthat/test-language.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
test_that("can temporarily change language", {
skip_if_not(has_nls())

expect_error(with_language("en", mean[[1]]), "not subsettable")
expect_error(with_language("fr", mean[[1]]), "non indi\u00e7able")
expect_error(with_language("es", mean[[1]]), "no es subconjunto")
expect_error(with_lang("en_GB", "en", mean[[1]]), "not subsettable")
expect_error(with_lang("fr_FR", "fr", mean[[1]]), "non indi\u00e7able")
expect_error(with_lang("es_ES", "es", mean[[1]]), "no es subconjunto")

# can use either _ or -
expect_error(with_language("pt_BR", mean[[1]]), "não possível dividir")
expect_error(with_language("pt-BR", mean[[1]]), "não possível dividir")
expect_error(with_lang("pt_BR", "pt_BR", mean[[1]]), "não possível dividir")
expect_error(with_lang("pt_BR", "pt-BR", mean[[1]]), "não possível dividir")
})

test_that("warns if LANG=C", {
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-timezone.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("with_timezone", {
expect_true(
with_timezone("CET", format(Sys.time(), "%Z")) %in% c("CET", "CEST"))
expect_true(
with_timezone("US/Pacific", format(Sys.time(), "%Z")) %in% c("PDT", "PST"))
with_timezone("America/Los_Angeles", format(Sys.time(), "%Z")) %in% c("PDT", "PST"))

})

Expand All @@ -15,7 +15,7 @@ describe("with_timezone", {
expect_identical(cur, Sys.timezone())

cur <- Sys.timezone()
expect_equal(with_timezone("US/Pacific", Sys.timezone()), "US/Pacific")
expect_equal(with_timezone("America/Los_Angeles", Sys.timezone()), "America/Los_Angeles")
expect_identical(cur, Sys.timezone())
})
})
Expand All @@ -30,8 +30,8 @@ describe("local_timezone", {
with_timezone("CET", Sys.timezone()),
fun("CET"))
expect_identical(
with_timezone("US/Pacific", Sys.timezone()),
fun("US/Pacific"))
with_timezone("America/Los_Angeles", Sys.timezone()),
fun("America/Los_Angeles"))
})

it("restores the time zone", {
Expand All @@ -42,7 +42,7 @@ describe("local_timezone", {
}
fun("CET")
expect_identical(cur, Sys.timezone())
fun("US/Pacific")
fun("America/Los_Angeles")
expect_identical(cur, Sys.timezone())
})
})
Loading