From 4110fab6289f006e1b0afc327fbaa52fdfc53d99 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 24 Mar 2024 13:39:44 -0700 Subject: [PATCH] Return to strftime of gmtime in the test suite After further discussion in https://github.com/Perl/perl5/issues/22062, I'm convined the blead and Perl 5.39.9 behavior is a regression and calling strftime on gmtime should work correctly. Restore the previous test behavior, but retain the enhancement to avoid spurious failures at the day boundary. Partly reverts 34d8417903c6896f181fe7083643010f01eaff51. --- Changes | 3 --- t/man/devise-date.t | 32 +++++++++++--------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Changes b/Changes index 924c5b4..f530467 100644 --- a/Changes +++ b/Changes @@ -55,9 +55,6 @@ v6.0.0 - Not Released - Fix tests when NO_COLOR is set in the environment. (GitHub #20) - - Avoid using strftime on gmtime in the test suite, since its behavior is - unexpected in Perl blead. (GitHub #27) - 5.01 - 2022-12-25 - Guesswork (formatting rules based on heuristics intended for Perl diff --git a/t/man/devise-date.t b/t/man/devise-date.t index c65f8a0..f5726f3 100755 --- a/t/man/devise-date.t +++ b/t/man/devise-date.t @@ -52,27 +52,17 @@ is( 'devise_date honors POD_MAN_DATE over SOURCE_DATE_EPOCH', ); -# Check that an invalid SOURCE_DATE_EPOCH is not accepted. Be careful to -# avoid false failures if the test is run exactly at the transition from one -# day to the next. +# Check that an invalid SOURCE_DATE_EPOCH is not accepted and the code falls +# back on using the current time. Be careful to avoid false failures if the +# test is run exactly at the transition from one day to the next. local $ENV{POD_MAN_DATE} = undef; local $ENV{SOURCE_DATE_EPOCH} = '1482676620B'; -my ($year, $month, $day) = (gmtime())[5, 4, 3]; -my $expected_old = sprintf('%04d-%02d-%02d', $year + 1900, $month + 1, $day); +my $expected_old = strftime('%Y-%m-%d', gmtime()); my $seen = $parser->devise_date(); -($year, $month, $day) = (gmtime())[5, 4, 3]; -my $expected_new = sprintf('%04d-%02d-%02d', $year + 1900, $month + 1, $day); - -if ($expected_old eq $expected_new || $seen eq $expected_old) { - is( - $parser->devise_date, - $expected_old, - 'devise_date ignores invalid SOURCE_DATE_EPOCH', - ); -} else { - is( - $parser->devise_date, - $expected_new, - 'devise_date ignores invalid SOURCE_DATE_EPOCH', - ); -} +my $expected_new = strftime('%Y-%m-%d', gmtime()); +my $expected = ($seen eq $expected_old) ? $expected_old : $expected_new; +is( + $parser->devise_date, + $expected, + 'devise_date ignores invalid SOURCE_DATE_EPOCH', +);