testTzSys: fix test suite for non-glibc when using TZDIR #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If TZDIR was set to a directory differing from the system timezone
directory, the testTZSys test suite would fail on certain timezones
in certain configurations. We discovered this when building the tz
packaged in nixpkgs on macOS: We would provide our packaged tzdata via
TZDIR, but /usr/share/zoneinfo would still be accessible. Since Apple's
tzdata seem to be outdated, the tests fail consistently. This is because
the tzset(3) implementation of Apple's libSystem is “only”
POSIX-conforming and doesn't support the glibc invention of TZDIR. They
are not alone with this -- musl doesn't support it as well.
To work around this we can use POSIX behavior, however: If TZ is
prefixed with a ':', we can pass an absolute path and rely on the lookup
behavior implemented in tz itself.
Tested this change on macOS (with libSystem) and on NixOS (with glibc). A new release would be neat, so we don't have to carry this patch around for too long.