Skip to content

fix: prevent gh10.t from flapping by moving TZ setup to BEGIN#100

Merged
atoomic merged 2 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-issue-99
Mar 19, 2026
Merged

fix: prevent gh10.t from flapping by moving TZ setup to BEGIN#100
atoomic merged 2 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-issue-99

Conversation

@Koan-Bot
Copy link
Copy Markdown

@Koan-Bot Koan-Bot commented Mar 19, 2026

Summary

t/gh10.t was flapping because $ENV{TZ} and POSIX::tzset() were assigned at runtime, but Perl's use statements execute at compile time — before any runtime code regardless of textual order. On some platforms, restoring local $ENV{TZ} in the platform-check eval implicitly resets the C library timezone, and the subsequent runtime POSIX::tzset() did not reliably take effect before Time::Zone::tz_local_offset() populated its per-DST-flag cache with UTC offsets (returning GMT instead of PST/PDT).

Fixes #99

Changes

  • Move $ENV{TZ} = 'America/Los_Angeles' and POSIX::tzset() into a BEGIN block so the C library timezone is initialised before any module loads or localtime() calls
  • Remove the now-redundant local $ENV{TZ} from the platform-check eval (TZ is already set globally)
  • Fix the platform check: the old epoch (1352021105) has DST=0 in both LA and UTC, so UTC-only systems were not skipped. Replace 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

Test plan

  • prove -lv t/gh10.t passes all 3 subtests
  • prove -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

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>
@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Mar 19, 2026

Failure on windows from CI

POSIX::tzset not implemented on this architecture at t/gh10.t line 25.
BEGIN failed--compilation aborted at t/gh10.t line 26.
t/gh10.t .............. 

@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Mar 19, 2026

@Koan-Bot rebase

@atoomic atoomic marked this pull request as ready for review March 19, 2026 01:16
@atoomic atoomic self-assigned this Mar 19, 2026
@Koan-Bot
Copy link
Copy Markdown
Author

Rebase: fix: prevent gh10.t from flapping by moving TZ setup to BEGIN

Branch koan.atoomic/fix-issue-99 rebased onto main and force-pushed.

Diff: 1 file changed, 19 insertions(+), 15 deletions(-)

Review feedback was analyzed and applied.

Actions

  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-issue-99 onto upstream/main
  • Applied review feedback
  • Force-pushed koan.atoomic/fix-issue-99 to origin
  • CI passed

CI

CI passed.


Automated by Kōan

@atoomic atoomic merged commit 6302d3a into cpan-authors:main Mar 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GH#10/RT#80649 can be flapping

2 participants