Fix spec for Time::Location.load_local with TZ=nil #6740
Merged
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.
On POSIX systems, if environment variable
TZ
is not set,Time::Location.load_local
looks up the time zone setting in/etc/localtime
. However, if this file is not available (or invalid), the default valueUTC
is used.That breaks the spec, which assumes the return value to be always
Local
.This is an issue when
/etc/localtime
is not populated by default which makes it depend on OS configuration.The FreeBSD port contains a patch to disable this spec because it would fail on a clean install without time zone configured.
I changed the spec to pass when the returned location name is either
Local
orUTC
.