fix: prevent gh10.t from flapping by moving TZ setup to BEGIN#100
Merged
atoomic merged 2 commits intocpan-authors:mainfrom Mar 19, 2026
Merged
fix: prevent gh10.t from flapping by moving TZ setup to BEGIN#100atoomic merged 2 commits intocpan-authors:mainfrom
atoomic merged 2 commits intocpan-authors:mainfrom
Conversation
The test was flapping because $ENV{TZ} and POSIX::tzset() were set
at runtime (lines 36-37), but `use` statements execute at compile
time regardless of textual position. On some platforms, restoring
`local $ENV{TZ}` in the platform-check eval automatically resets the
C library timezone (via an implicit tzset), and the subsequent runtime
POSIX::tzset() call did not reliably undo this before Time::Zone's
tz_local_offset() populated its per-DST-flag cache.
Moving the TZ assignment and POSIX::tzset() into a BEGIN block ensures
the C library timezone is initialised to America/Los_Angeles before any
module loads or localtime() calls happen.
Also fix the platform check: the previous epoch (1352021105) has DST=0
in both America/Los_Angeles and UTC, so a UTC-only system would not
be skipped and would produce failing results. Replace it with epoch
1352019262 (2012-11-04 01:04:22 PDT) which has DST=1 in LA and DST=0
in UTC — a check that actually distinguishes the two.
Fixes cpan-authors#99
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
Failure on windows from CI |
Collaborator
|
@Koan-Bot rebase |
Author
Rebase: fix: prevent gh10.t from flapping by moving TZ setup to BEGINBranch Diff: 1 file changed, 19 insertions(+), 15 deletions(-) Review feedback was analyzed and applied. Actions
CICI passed. Automated by Kōan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
t/gh10.twas flapping because$ENV{TZ}andPOSIX::tzset()were assigned at runtime, but Perl'susestatements execute at compile time — before any runtime code regardless of textual order. On some platforms, restoringlocal $ENV{TZ}in the platform-checkevalimplicitly resets the C library timezone, and the subsequent runtimePOSIX::tzset()did not reliably take effect beforeTime::Zone::tz_local_offset()populated its per-DST-flag cache with UTC offsets (returningGMTinstead ofPST/PDT).Fixes #99
Changes
$ENV{TZ} = 'America/Los_Angeles'andPOSIX::tzset()into aBEGINblock so the C library timezone is initialised before any module loads orlocaltime()callslocal $ENV{TZ}from the platform-checkeval(TZ is already set globally)Test plan
prove -lv t/gh10.tpasses all 3 subtestsprove -l t/full suite passes (27 files, 1217 tests)Generated by Kōan /fix
Quality Report
Changes: 1 file changed, 19 insertions(+), 15 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline