From: Steve Hay Date: Tue, 12 May 2009 17:02:15 +0000 (+0100) Subject: Skip test for changing TZ if running in a pseudo-fork (on Win32) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8177d4d97c5035e1ca045371b1be47a2ef66ec1d;p=p5sagit%2Fp5-mst-13.2.git Skip test for changing TZ if running in a pseudo-fork (on Win32) Changing $ENV{TZ} and calling tzset() is documented not to work on Win32 in any thread other than the main thread, which includes the emulated fork() on Win32 (used by cpantesters?). Mention fork() in the caveats and skip the test in this case. --- diff --git a/ext/Time-Piece/Piece.pm b/ext/Time-Piece/Piece.pm index abdf588..302114f 100644 --- a/ext/Time-Piece/Piece.pm +++ b/ext/Time-Piece/Piece.pm @@ -22,7 +22,7 @@ our %EXPORT_TAGS = ( ':override' => 'internal', ); -our $VERSION = '1.14'; +our $VERSION = '1.14_01'; bootstrap Time::Piece $VERSION; @@ -835,6 +835,9 @@ subsequently call that with the %Z formatting code. You must change $ENV{TZ} in the main thread to have the desired effect in this case (and you must also call _tzset() in the main thread to register the environment change). +Furthermore, remember that this caveat also applies to fork(), which is +emulated by threads on Win32. + =head1 AUTHOR Matt Sergeant, matt@sergeant.org diff --git a/ext/Time-Piece/t/02core.t b/ext/Time-Piece/t/02core.t index 7ca22a9..5610bcb 100644 --- a/ext/Time-Piece/t/02core.t +++ b/ext/Time-Piece/t/02core.t @@ -47,7 +47,13 @@ cmp_ok($t->datetime, 'eq','2000-02-29T12:34:56'); cmp_ok($t->daylight_savings, '==', 0); # ->tzoffset? -{ +my $is_pseudo_fork = 0; +if (defined &Win32::GetCurrentProcessId + ? $$ != Win32::GetCurrentProcessId() : $^O eq "MSWin32" && $$ < 0) { + $is_pseudo_fork = 1; +} +SKIP: { + skip "can't register TZ changes in a pseudo-fork", 2 if $is_pseudo_fork; local $ENV{TZ} = "EST5"; Time::Piece::_tzset(); # register the environment change my $lt = localtime;