From kirill at altlinux.org  Wed May 17 20:01:59 2017
From: kirill at altlinux.org (Kirill Maslinsky)
Date: Wed, 17 May 2017 21:01:59 +0300
Subject: [Rd] problem running test on a system without /etc/localtime
In-Reply-To: <22812.6124.879696.821362@stat.math.ethz.ch>
References: <20170517003539.GA31461@imap.altlinux.org>
 <CAFDcVCTOOxBqaL0+m7Y8xHzZsDMVh7ZN1VFpuw9Y+SOXnbPi5A@mail.gmail.com>
 <22812.6124.879696.821362@stat.math.ethz.ch>
Message-ID: <20170517180159.GA12344@imap.altlinux.org>

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



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