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

Kirill Maslinsky kirill at altlinux.org
Wed May 17 02:35:39 CEST 2017


Hi all, 

A problem with tests while building R.

I'm packaging R for Sisyphus repository and package build environment,
by design, doesn't have /etc/localtime file present. This causes failure
with Sys.timeone during test run:

[builder at localhost tests]$ ../bin/R --vanilla < reg-tests-1d.R

> ## PR#17186 - Sys.timezone() on some Debian-derived platforms
> (S.t <- Sys.timezone())
Error in normalizePath("/etc/localtime") : 
  (converted from warning) path[1]="/etc/localtime": No such file or
  directory
  Calls: Sys.timezone -> normalizePath
  Execution halted

This is caused by this code:

> Sys.timezone
function (location = TRUE) 
{
    tz <- Sys.getenv("TZ", names = FALSE)
    if (!location || nzchar(tz)) 
        return(Sys.getenv("TZ", unset = NA_character_))
>>  lt <- normalizePath("/etc/localtime")
[remainder of the code skkipped]

File /etc/loclatime is optional and is not guaranteed to be present on
any platform. And anyway, it is a good idea to first check that file 
exists before calling normalizePath. 

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

It seems that the best solution will be to patch Sys.timezone.

-- 
KM



More information about the R-devel mailing list