r-lib / clock

A Date-Time Library for R
https://clock.r-lib.org
Other
102 stars 5 forks source link

Test suite failures in 32bit architectures #312

Closed tillea closed 1 year ago

tillea commented 1 year ago

Hi, I have packaged clock for Debian. The test suite is run on several architectures. Unfortunately there are two failing tests for i386, armel and armhf. As an example here is the full test log for i386 which contains:

══ Skipped tests ═══════════════════════════════════════════════════════════════
• On CRAN (252)

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-posixt.R:151'): can group by year/month/day/hour/minute/second ──
date_group(z, "year") (`actual`) not identical to `expect` (`expected`).

    actual              | expected
[1] "-1-12-31 23:56:02" - "0-01-01" [1]
[2] "0-12-31 23:56:02"  - "1-01-01" [2]
[3] "1-12-31 23:56:02"  - "2-01-01" [3]
[4] "2-12-31 23:56:02"  - "3-01-01" [4]
[5] "3-12-31 23:56:02"  - "4-01-01" [5]
── Failure ('test-posixt.R:152'): can group by year/month/day/hour/minute/second ──
date_group(z, "year", n = 3) (`actual`) not identical to expect[c(1, 1, 1, 4, 4)] (`expected`).

    actual              | expected
[1] "-1-12-31 23:56:02" - "0-01-01" [1]
[2] "-1-12-31 23:56:02" - "0-01-01" [2]
[3] "-1-12-31 23:56:02" - "0-01-01" [3]
[4] "2-12-31 23:56:02"  - "3-01-01" [4]
[5] "2-12-31 23:56:02"  - "3-01-01" [5]

[ FAIL 2 | WARN 29 | SKIP 252 | PASS 1146 ]
Error: Test failures
Execution halted

This was reported in a Debian bug report. Kind regards, Andreas.

DavisVaughan commented 1 year ago

I believe this is actually the result of a base R bug on 32-bit Linux systems

Reproducible with:

docker run -ti --platform linux/386 debian:stable bash
apt update
apt install curl
apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common
apt install r-base
R

UTC example, everything looks good:

# MY COMPUTER (64 bit Mac)
> x <- as.POSIXct("0000-01-05", tz = "UTC") 
> x
[1] "0000-01-05 UTC"
> unclass(x)
[1] -62166873600
attr(,"tzone")
[1] "UTC"

# 32 BIT LINUX CONTAINER
> x <- as.POSIXct("0000-01-05", tz = "UTC")   
> x
[1] "0-01-05 UTC"
> unclass(x)
[1] -62166873600
attr(,"tzone")
[1] "UTC"

America/New_York example, this is weird - note the similar print output, but differing underlying numeric values:

# MY COMPUTER (64 bit Mac)
> x <- as.POSIXct("0000-01-05", tz = "America/New_York") 
> x
[1] "0000-01-05 LMT"
> unclass(x)
[1] -62166855838
attr(,"tzone")
[1] "America/New_York"

# 32 BIT LINUX CONTAINER
> x <- as.POSIXct("0000-01-05", tz = "America/New_York")
> x
[1] "0-01-05 EST"
> unclass(x)
[1] -62166855600
attr(,"tzone")
[1] "America/New_York"

If you take that Linux value of -62166855600 into my computer it shows

> .POSIXct(-62166855600, tz = "America/New_York")
[1] "0000-01-05 00:03:58 LMT"

which is exactly 3 minutes and 58 seconds off, which corresponds to the amount of difference seen in the failing test!

So I imagine this is a base R issue on 32 bit Linux somehow. I can report it to R-devel, and I'll just skip these tests on 32 bit systems.

tillea commented 1 year ago

Am Thu, Apr 13, 2023 at 12:51:55PM -0700 schrieb Davis Vaughan:

... which is exactly 3 minutes and 58 seconds off, which corresponds to the amount of difference seen in the failing test!

Makes sense.

So I imagine this is a base R issue on 32 bit Linux somehow. I can report it to R-devel, and I'll just skip these tests on 32 bit systems.

Thanks a lot for caring, Andreas.