File: newtests-perldelta.pl

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (92 lines) | stat: -rwxr-xr-x 1,827 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!perl -w
use 5.010;
use strict;
use Getopt::Long;
use Pod::Usage;
use Module::CoreList;
GetOptions(
    'spec|s:s' => \my $manifest,
) or pod2usage();

=head1 SYNOPSIS

  newtests-perldelta.pl [FROM TO]

Output the added tests between the two last released versions of Perl

  newtests-perldelta.pl

Output the added tests between the version tagged v5.11.1
and this version

  newtests-perldelta.pl v5.11.1 HEAD

=cut

my $corelist = \%Module::CoreList::version;
my @versions = sort keys %$corelist;

# by default, compare latest two version in CoreList;
my ($from, $to) = @ARGV;

# Convert the numbers to git version tags
sub num2git {
    my ($num) = @_;
    $num =~ /^(5)\.(\d\d\d)(\d\d\d)/
        or die "Couldn't make sense of version number '$num'";
    sprintf 'v%d.%d.%d', $1,$2,$3;
};

$from //= num2git($versions[-2]); # /
$to   //= num2git($versions[-1]); # /
$manifest //= 'MANIFEST'; # /

warn "Finding newly added tests between $from..$to\n";

my @new_tests =
    grep { m!^[-+](?:t|ext)/.*\.t\s+! } # only added/removed tests
    `git diff $from..$to -- $manifest`;
chomp @new_tests;
if (! @new_tests) {
    die "No new tests found between $from and $to.";
};

# Now remove those files whose lines were just shuffled around
# within MANIFEST
my %desc;
my %removed;
for (@new_tests) {
    die "Weird diff line '$_' " unless /^([+-])(\S+\.t)(?:\s+(.*))?$/;
    my ($mod,$file,$desc) = ($1,$2,$3);
    $desc //= '<no description>'; # / to placate Padre highlighting
    if ($mod eq '-') {
        $removed{ $file } = $file;
    };
    $desc{ $file } = $desc;
};

print <<HEAD;

=head1 New Tests

Many modules updated from CPAN incorporate new tests.

=over 4

HEAD

for my $file (sort keys %desc) {
    next if $removed{ $file };
    print <<ITEM;
=item $file

$desc{ $file }

ITEM
};

print <<TAIL

=back

TAIL