Skip to content

Commit

Permalink
Return to strftime of gmtime in the test suite
Browse files Browse the repository at this point in the history
After further discussion in Perl/perl5#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 34d8417.
  • Loading branch information
rra committed Mar 24, 2024
1 parent 53293fa commit 4110fab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
3 changes: 0 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 11 additions & 21 deletions t/man/devise-date.t
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

0 comments on commit 4110fab

Please sign in to comment.