From 90bd495740e7386ba55ecf3306545b7bee061a75 Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Feb 14 2020 13:17:50 +0000 Subject: Fix Time-Local tests to pass after year 2019 --- diff --git a/perl-5.28.2-Only-pass-2-digit-years-to-tests-when-testing-2-digi.patch b/perl-5.28.2-Only-pass-2-digit-years-to-tests-when-testing-2-digi.patch new file mode 100644 index 0000000..4fb8553 --- /dev/null +++ b/perl-5.28.2-Only-pass-2-digit-years-to-tests-when-testing-2-digi.patch @@ -0,0 +1,113 @@ +From 381d51822fccaa333cbd0ab9fca8b69f650c05f9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 14 Feb 2020 14:10:10 +0100 +Subject: [PATCH] Only pass 2-digit years to tests when testing 2-digit year + handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This will start breaking in 2020 if done without working around the whole +breakpoint thing. See https://rt.cpan.org/Ticket/Display.html?id=124787. + +Ported from Time-Local 63265fd81c7f6177bf28dfe0d1ada9cb897de566 commit +by Dave Rolsky to perl 5.28.2. + +Signed-off-by: Petr Písař +--- + cpan/Time-Local/t/Local.t | 40 +++++++++++++++++++++++++++++---------- + 1 file changed, 30 insertions(+), 10 deletions(-) + +diff --git a/cpan/Time-Local/t/Local.t b/cpan/Time-Local/t/Local.t +index 6341396..701d22d 100644 +--- a/cpan/Time-Local/t/Local.t ++++ b/cpan/Time-Local/t/Local.t +@@ -85,19 +85,17 @@ my $epoch_is_64 + + for ( @time, @neg_time ) { + my ( $year, $mon, $mday, $hour, $min, $sec ) = @$_; +- $year -= 1900; + $mon--; + + SKIP: { + skip '1970 test on VOS fails.', 12 +- if $^O eq 'vos' && $year == 70; ++ if $^O eq 'vos' && $year == 1970; + skip 'this platform does not support negative epochs.', 12 +- if $year < 70 && !$neg_epoch_ok; ++ if $year < 1970 && !$neg_epoch_ok; + + # Test timelocal() + { +- my $year_in = $year < 70 ? $year + 1900 : $year; +- my $time = timelocal( $sec, $min, $hour, $mday, $mon, $year_in ); ++ my $time = timelocal( $sec, $min, $hour, $mday, $mon, $year ); + + my ( $s, $m, $h, $D, $M, $Y ) = localtime($time); + +@@ -106,13 +104,12 @@ SKIP: { + is( $h, $hour, "timelocal hour for @$_" ); + is( $D, $mday, "timelocal day for @$_" ); + is( $M, $mon, "timelocal month for @$_" ); +- is( $Y, $year, "timelocal year for @$_" ); ++ is( $Y, $year - 1900, "timelocal year for @$_" ); + } + + # Test timegm() + { +- my $year_in = $year < 70 ? $year + 1900 : $year; +- my $time = timegm( $sec, $min, $hour, $mday, $mon, $year_in ); ++ my $time = timegm( $sec, $min, $hour, $mday, $mon, $year ); + + my ( $s, $m, $h, $D, $M, $Y ) = gmtime($time); + +@@ -121,14 +118,13 @@ SKIP: { + is( $h, $hour, "timegm hour for @$_" ); + is( $D, $mday, "timegm day for @$_" ); + is( $M, $mon, "timegm month for @$_" ); +- is( $Y, $year, "timegm year for @$_" ); ++ is( $Y, $year - 1900, "timegm year for @$_" ); + } + } + } + + for (@bad_time) { + my ( $year, $mon, $mday, $hour, $min, $sec ) = @$_; +- $year -= 1900; + $mon--; + + eval { timegm( $sec, $min, $hour, $mday, $mon, $year ) }; +@@ -229,6 +225,30 @@ SKIP: + ); + } + ++# 2-digit years ++{ ++ my $current_year = ( localtime() )[5]; ++ my $pre_break = ( $current_year + 49 ) - 100; ++ my $break = ( $current_year + 50 ) - 100; ++ my $post_break = ( $current_year + 51 ) - 100; ++ ++ is( ++ ( ( localtime( timelocal( 0, 0, 0, 1, 1, $pre_break ) ) )[5] ), ++ $pre_break + 100, ++ "year $pre_break is treated as next century", ++ ); ++ is( ++ ( ( localtime( timelocal( 0, 0, 0, 1, 1, $break ) ) )[5] ), ++ $break + 100, ++ "year $break is treated as next century", ++ ); ++ is( ++ ( ( localtime( timelocal( 0, 0, 0, 1, 1, $post_break ) ) )[5] ), ++ $post_break, ++ "year $post_break is treated as current century", ++ ); ++} ++ + SKIP: + { + skip 'These tests only run for the package maintainer.', 8 +-- +2.21.1 + diff --git a/perl.spec b/perl.spec index c9dd0a8..4b08369 100644 --- a/perl.spec +++ b/perl.spec @@ -83,7 +83,7 @@ License: GPL+ or Artistic Epoch: %{perl_epoch} Version: %{perl_version} # release number must be even higher, because dual-lived modules will be broken otherwise -Release: 441%{?dist} +Release: 442%{?dist} Summary: Practical Extraction and Report Language Url: https://www.perl.org/ Source0: https://www.cpan.org/src/5.0/perl-%{perl_version}.tar.xz @@ -410,6 +410,10 @@ Patch113: perl-5.28.2-Adapt-Configure-to-GCC-version-10.patch # GH#17218, in upsream after 5.31.5 Patch114: perl-5.31.5-PATCH-gh-17218-memory-leak.patch +# Fix Time-Local tests to pass after year 2019, CPAN RT#124787, GH#17410, +# in Time-Local-1.26 +Patch115: perl-5.28.2-Only-pass-2-digit-years-to-tests-when-testing-2-digi.patch + # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048 Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch @@ -3070,6 +3074,7 @@ Perl extension for Version Objects %patch112 -p1 %patch113 -p1 %patch114 -p1 +%patch115 -p1 %patch200 -p1 %patch201 -p1 @@ -3168,6 +3173,7 @@ perl -x patchlevel.h \ 'Fedora Patch112: Fix a race in File::stat() tests (GH#17234)' \ 'Fedora Patch113: Fix GCC 10 version detection (GH#17295)' \ 'Fedora Patch114: Fix a memory leak when compiling a regular expression with a non-word class (GH#17218)' \ + 'Fedora Patch115: Fix Time-Local tests to pass after year 2019 (CPAN RT#124787)' \ 'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \ 'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \ %{nil} @@ -5456,6 +5462,9 @@ popd # Old changelog entries are preserved in CVS. %changelog +* Fri Feb 14 2020 Petr Pisar - 4:5.28.2-442 +- Fix Time-Local tests to pass after year 2019 (CPAN RT#124787) + * Fri Nov 29 2019 Petr Pisar - 4:5.28.2-441 - Avoid panic when last value of search-and-replace is tainted and UTF-8 (RT#134409)