[Rd] problem running test on a system without /etc/localtime

Kirill Maslinsky kirill at altlinux.org
Wed May 17 20:01:59 CEST 2017


On Wed, May 17, 2017 at 11:29:16AM +0200, Martin Maechler wrote:

[...]

> 
> 
>     > Index: src/library/base/R/datetime.R
>     > ===================================================================
>     > --- src/library/base/R/datetime.R (revision 72684)
>     > +++ src/library/base/R/datetime.R (working copy)
>     > @@ -23,7 +23,7 @@
>     > {
>     > tz <- Sys.getenv("TZ", names = FALSE)
>     > if(!location || nzchar(tz)) return(Sys.getenv("TZ", unset = NA_character_))
>     > -    lt <- normalizePath("/etc/localtime") # Linux, macOS, ...
>     > +    lt <- normalizePath("/etc/localtime", mustWork = FALSE) # Linux, macOS, ...
>     > if (grepl(pat <- "^/usr/share/zoneinfo/", lt)) sub(pat, "", lt)
>     > else if (lt == "/etc/localtime" && file.exists("/etc/timezone") &&
>     > dir.exists("/usr/share/zoneinfo") &&

Done, the patch successfully fixes warning but the test failed in the other way:

$ ../bin/R --vanilla < reg-tests-1d.R

> ## PR#17186 - Sys.timezone() on some Debian-derived platforms
> (S.t <- Sys.timezone())
[1] NA
> if(is.na(S.t) || !nzchar(S.t)) stop("could not get timezone")
Error: could not get timezone
Execution halted

Which is technically correct, timezone is not set on the system, but date
utility assumes UTC in this case:

$ date +%Z
UTC

I'm not sure if R should do the same. 


Probably, setting TZ environment variable is the right way to go in this
build environment, but then another failure should be fixed:

>     >> Sure, this can be worked around by setting TZ environment variable, but
>     >> that causes tests to fail in another place:
>     >> 
>     >> [builder at localhost tests]$ TZ="GMT" ../bin/R --vanilla < reg-tests-1d.R
>     >> 
>     >>> ## format()ing invalid hand-constructed  POSIXlt  objects
>     >>> d <- as.POSIXlt("2016-12-06"); d$zone <- 1
>     >>> tools::assertError(format(d))
>     >> Error: Failed to get error in evaluating format(d)
>     >> Execution halted

-- 
KM



More information about the R-devel mailing list