1*f2a19305Safresh1#!./perl -w 2*f2a19305Safresh1 3*f2a19305Safresh1BEGIN { 4*f2a19305Safresh1 chdir 't' if -d 't'; 5*f2a19305Safresh1 require "./test.pl"; 6*f2a19305Safresh1 set_up_inc('../lib', '..'); 7*f2a19305Safresh1} 8*f2a19305Safresh1 9*f2a19305Safresh1use TestInit qw(T); # T is chdir to the top level 10*f2a19305Safresh1use strict; 11*f2a19305Safresh1 12*f2a19305Safresh1find_git_or_skip('all'); 13*f2a19305Safresh1 14*f2a19305Safresh1my $ok= do "./Porting/updateAUTHORS.pl"; 15*f2a19305Safresh1my $error= !$ok && $@; 16*f2a19305Safresh1is($ok,1,"updateAUTHORS.pl compiles correctly"); 17*f2a19305Safresh1is($error, "", "updateAUTHORS.pl compiles without error"); 18*f2a19305Safresh1my $small_range= "544171f79ec3e50bb5003007e9f4ebb9a7e9fe84^^^" 19*f2a19305Safresh1 . "..544171f79ec3e50bb5003007e9f4ebb9a7e9fe84"; 20*f2a19305Safresh1my $large_range= "6d02a9e121d037896df9b91ac623c1ab4c98c99a.." 21*f2a19305Safresh1 . "544171f79ec3e50bb5003007e9f4ebb9a7e9fe8"; 22*f2a19305Safresh1my $with_unknown_range= "96a91e01636d3050d38ae3373a362c7d47a6647e^^^.." 23*f2a19305Safresh1 . "96a91e01636d3050d38ae3373a362c7d47a6647e"; 24*f2a19305Safresh1 25*f2a19305Safresh1foreach my $tuple ( 26*f2a19305Safresh1 [ "--who", $small_range, 27*f2a19305Safresh1 "James E Keenan, Karl Williamson, Mark Shelor." ], 28*f2a19305Safresh1 [ "--files", $small_range, files_expected() ], 29*f2a19305Safresh1 [ "--rank", $large_range, rank_expected()], 30*f2a19305Safresh1 [ "--rank --percentage", $large_range, rank_percentage_expected()], 31*f2a19305Safresh1 [ "--rank --percentage --cumulative", $large_range, 32*f2a19305Safresh1 rank_percentage_cumulative_expected()], 33*f2a19305Safresh1 [ "--thanks-applied", $large_range, thanks_applied_expected() ], 34*f2a19305Safresh1 [ "--stats", $large_range, stats_expected() ], 35*f2a19305Safresh1 [ "--stats --numstat", $large_range, stats_numstat_expected() ], 36*f2a19305Safresh1 [ "--who" , $with_unknown_range, "Jarkko Hietaniemi.", "(no 'unknown' authors)" ], 37*f2a19305Safresh1) { 38*f2a19305Safresh1 my ($arg,$range,$expect, $msg_extra)= @$tuple; 39*f2a19305Safresh1 my $skip_it; 40*f2a19305Safresh1 for my $endpoint (split /\.+/, $range) { 41*f2a19305Safresh1 my $parsed= `git rev-parse --verify -q $endpoint\{commit}`; 42*f2a19305Safresh1 if (!$parsed or $?) { 43*f2a19305Safresh1 $skip_it = 1; 44*f2a19305Safresh1 } 45*f2a19305Safresh1 } 46*f2a19305Safresh1 SKIP: { 47*f2a19305Safresh1 if ($skip_it) { 48*f2a19305Safresh1 skip "commit range '$range' not available (this happens in CI)", 1; 49*f2a19305Safresh1 } 50*f2a19305Safresh1 $msg_extra= $msg_extra ? " $msg_extra" : ""; 51*f2a19305Safresh1 my $cmd= join " ", "$^X ./Porting/updateAUTHORS.pl", 52*f2a19305Safresh1 $arg, $range; 53*f2a19305Safresh1 my $result= `$cmd`; 54*f2a19305Safresh1 is(_clean($result), _clean($expect),"Option '$arg' works as expected$msg_extra") 55*f2a19305Safresh1 or print STDERR "$cmd\n",$result 56*f2a19305Safresh1 } 57*f2a19305Safresh1} 58*f2a19305Safresh1done_testing(); 59*f2a19305Safresh1exit 0; 60*f2a19305Safresh1sub _clean { 61*f2a19305Safresh1 my ($str)= @_; 62*f2a19305Safresh1 $str=~s/\s+\z//; 63*f2a19305Safresh1 $str=~s/[ ]+\n/\n/g; 64*f2a19305Safresh1 return $str; 65*f2a19305Safresh1} 66*f2a19305Safresh1 67*f2a19305Safresh1sub files_expected { 68*f2a19305Safresh1 return <<'END_OF_REPORT'; 69*f2a19305Safresh1#Pos | commits | L++ | L-- | L+- | binary_change | Name 70*f2a19305Safresh1#----+---------+-----+-----+-----+---------------+---------------------------------- 71*f2a19305Safresh1#1 | 1 | 28 | 0 | 28 | 0 | pod/perlfunc.pod 72*f2a19305Safresh1#2 | 1 | 14 | 4 | 10 | 0 | cpan/Digest-SHA/lib/Digest/SHA.pm 73*f2a19305Safresh1#3 | 1 | 5 | 5 | 0 | 0 | cpan/Digest-SHA/shasum 74*f2a19305Safresh1#4 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha64bit.c 75*f2a19305Safresh1#5 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha64bit.h 76*f2a19305Safresh1#6 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha.c 77*f2a19305Safresh1#7 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha.h 78*f2a19305Safresh1#8 | 1 | 1 | 1 | 0 | 0 | Porting/Maintainers.pl 79*f2a19305Safresh1#9 | 1 | 1 | 0 | 1 | 0 | AUTHORS 80*f2a19305Safresh1END_OF_REPORT 81*f2a19305Safresh1} 82*f2a19305Safresh1 83*f2a19305Safresh1sub rank_expected { 84*f2a19305Safresh1 return <<'END_OF_REPORT'; 85*f2a19305Safresh1#Pos | Authored | Name 86*f2a19305Safresh1#----+----------+----------------- 87*f2a19305Safresh1#1 | 40 | Karl Williamson 88*f2a19305Safresh1#2 | 32 | Yves Orton 89*f2a19305Safresh1#3 | 8 | Paul Evans 90*f2a19305Safresh1#4 | 6 | James E Keenan 91*f2a19305Safresh1#5 | 4 | Elvin Aslanov 92*f2a19305Safresh1#6 | 3 | Richard Leach 93*f2a19305Safresh1#7 | 3 | Tony Cook 94*f2a19305Safresh1#8 | 2 | Nicholas Clark 95*f2a19305Safresh1#9 | 1 | Dan Kogai 96*f2a19305Safresh1#10 | 1 | David Golden 97*f2a19305Safresh1#11 | 1 | Graham Knop 98*f2a19305Safresh1#12 | 1 | Mark Shelor 99*f2a19305Safresh1#13 | 1 | Tomasz Konojacki 100*f2a19305Safresh1END_OF_REPORT 101*f2a19305Safresh1} 102*f2a19305Safresh1 103*f2a19305Safresh1sub rank_percentage_expected { 104*f2a19305Safresh1 return <<'END_OF_REPORT'; 105*f2a19305Safresh1#Pos | %Authored | Name 106*f2a19305Safresh1#----+-----------+----------------- 107*f2a19305Safresh1#1 | 38.83 | Karl Williamson 108*f2a19305Safresh1#2 | 31.07 | Yves Orton 109*f2a19305Safresh1#3 | 7.77 | Paul Evans 110*f2a19305Safresh1#4 | 5.83 | James E Keenan 111*f2a19305Safresh1#5 | 3.88 | Elvin Aslanov 112*f2a19305Safresh1#6 | 2.91 | Richard Leach 113*f2a19305Safresh1#7 | 2.91 | Tony Cook 114*f2a19305Safresh1#8 | 1.94 | Nicholas Clark 115*f2a19305Safresh1#9 | 0.97 | Dan Kogai 116*f2a19305Safresh1#10 | 0.97 | David Golden 117*f2a19305Safresh1#11 | 0.97 | Graham Knop 118*f2a19305Safresh1#12 | 0.97 | Mark Shelor 119*f2a19305Safresh1#13 | 0.97 | Tomasz Konojacki 120*f2a19305Safresh1END_OF_REPORT 121*f2a19305Safresh1} 122*f2a19305Safresh1 123*f2a19305Safresh1sub rank_percentage_cumulative_expected { 124*f2a19305Safresh1 return <<'END_OF_REPORT'; 125*f2a19305Safresh1#Pos | %Authored | Name 126*f2a19305Safresh1#----+-----------+----------------- 127*f2a19305Safresh1#1 | 38.83 | Karl Williamson 128*f2a19305Safresh1#2 | 69.90 | Yves Orton 129*f2a19305Safresh1#3 | 77.67 | Paul Evans 130*f2a19305Safresh1#4 | 83.50 | James E Keenan 131*f2a19305Safresh1#5 | 87.38 | Elvin Aslanov 132*f2a19305Safresh1#6 | 90.29 | Richard Leach 133*f2a19305Safresh1#7 | 93.20 | Tony Cook 134*f2a19305Safresh1#8 | 95.15 | Nicholas Clark 135*f2a19305Safresh1#9 | 96.12 | Dan Kogai 136*f2a19305Safresh1#10 | 97.09 | David Golden 137*f2a19305Safresh1#11 | 98.06 | Graham Knop 138*f2a19305Safresh1#12 | 99.03 | Mark Shelor 139*f2a19305Safresh1#13 | 100.00 | Tomasz Konojacki 140*f2a19305Safresh1END_OF_REPORT 141*f2a19305Safresh1} 142*f2a19305Safresh1 143*f2a19305Safresh1sub thanks_applied_expected { 144*f2a19305Safresh1 return <<'END_OF_REPORT'; 145*f2a19305Safresh1#Pos | Applied | Name 146*f2a19305Safresh1#----+---------+---------------- 147*f2a19305Safresh1#1 | 7 | Karl Williamson 148*f2a19305Safresh1#2 | 4 | James E Keenan 149*f2a19305Safresh1END_OF_REPORT 150*f2a19305Safresh1} 151*f2a19305Safresh1 152*f2a19305Safresh1sub stats_expected { 153*f2a19305Safresh1 return <<'END_OF_REPORT'; 154*f2a19305Safresh1#Pos | Authored | Applied | Committed | Name 155*f2a19305Safresh1#----+----------+---------+-----------+----------------- 156*f2a19305Safresh1#1 | 40 | 7 | 47 | Karl Williamson 157*f2a19305Safresh1#2 | 32 | 0 | 31 | Yves Orton 158*f2a19305Safresh1#3 | 8 | 0 | 8 | Paul Evans 159*f2a19305Safresh1#4 | 6 | 4 | 10 | James E Keenan 160*f2a19305Safresh1#5 | 4 | 0 | 1 | Elvin Aslanov 161*f2a19305Safresh1#6 | 3 | 0 | 3 | Tony Cook 162*f2a19305Safresh1#7 | 3 | 0 | 0 | Richard Leach 163*f2a19305Safresh1#8 | 2 | 0 | 2 | Nicholas Clark 164*f2a19305Safresh1#9 | 1 | 0 | 1 | Tomasz Konojacki 165*f2a19305Safresh1#10 | 1 | 0 | 0 | Dan Kogai 166*f2a19305Safresh1#11 | 1 | 0 | 0 | David Golden 167*f2a19305Safresh1#12 | 1 | 0 | 0 | Graham Knop 168*f2a19305Safresh1#13 | 1 | 0 | 0 | Mark Shelor 169*f2a19305Safresh1END_OF_REPORT 170*f2a19305Safresh1} 171*f2a19305Safresh1 172*f2a19305Safresh1sub stats_numstat_expected { 173*f2a19305Safresh1 return <<'END_OF_REPORT'; 174*f2a19305Safresh1#Pos | Authored | Applied | Committed | NFiles | L++ | L-- | L+- | Name 175*f2a19305Safresh1#----+----------+---------+-----------+--------+------+------+------+----------------- 176*f2a19305Safresh1#1 | 40 | 7 | 47 | 14 | 1179 | 874 | 305 | Karl Williamson 177*f2a19305Safresh1#2 | 32 | 0 | 31 | 25 | 2547 | 1481 | 1066 | Yves Orton 178*f2a19305Safresh1#3 | 8 | 0 | 8 | 15 | 161 | 102 | 59 | Paul Evans 179*f2a19305Safresh1#4 | 6 | 4 | 10 | 4 | 44 | 11 | 33 | James E Keenan 180*f2a19305Safresh1#5 | 4 | 0 | 1 | 4 | 16 | 13 | 3 | Elvin Aslanov 181*f2a19305Safresh1#6 | 3 | 0 | 3 | 7 | 8 | 7 | 1 | Tony Cook 182*f2a19305Safresh1#7 | 3 | 0 | 0 | 13 | 75 | 51 | 24 | Richard Leach 183*f2a19305Safresh1#8 | 2 | 0 | 2 | 2 | 24 | 1 | 23 | Nicholas Clark 184*f2a19305Safresh1#9 | 1 | 0 | 1 | 2 | 21 | 15 | 6 | Tomasz Konojacki 185*f2a19305Safresh1#10 | 1 | 0 | 0 | 8 | 33 | 22 | 11 | Mark Shelor 186*f2a19305Safresh1#11 | 1 | 0 | 0 | 5 | 93 | 7 | 86 | Graham Knop 187*f2a19305Safresh1#12 | 1 | 0 | 0 | 4 | 9 | 4 | 5 | Dan Kogai 188*f2a19305Safresh1#13 | 1 | 0 | 0 | 2 | 19 | 6 | 13 | David Golden 189*f2a19305Safresh1END_OF_REPORT 190*f2a19305Safresh1} 191