summaryrefslogtreecommitdiff
path: root/t/porting
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-08-11 16:02:57 +0200
committerYves Orton <demerphq@gmail.com>2022-08-21 12:09:05 +0200
commit40c26f0c37ae90c90b3db1887343c857d0f78d49 (patch)
treeacd5ed5e237e5fc74cb4a0cd24ca40f06ab21047 /t/porting
parent921bc9a5068bda5c083f97cd2fd08273db3870a9 (diff)
downloadperl-40c26f0c37ae90c90b3db1887343c857d0f78d49.tar.gz
updateAUTHORS.p[lm] - add support for reports like checkAUTHORS.pl has
Adds the --stats, --files, --who, and related options similar to what checkAUTHORS.pl offers. See perldoc Porting/updateAUTHORS.pl for the list of options it supports.
Diffstat (limited to 't/porting')
-rw-r--r--t/porting/update_authors.t164
1 files changed, 164 insertions, 0 deletions
diff --git a/t/porting/update_authors.t b/t/porting/update_authors.t
index 9bd76a9671..589deeb3f7 100644
--- a/t/porting/update_authors.t
+++ b/t/porting/update_authors.t
@@ -15,5 +15,169 @@ my $ok= do "./Porting/updateAUTHORS.pl";
my $error= !$ok && $@;
is($ok,1,"updateAUTHORS.pl compiles correctly");
is($error, "", "updateAUTHORS.pl compiles without error");
+my $small_range= "544171f79ec3e50bb5003007e9f4ebb9a7e9fe84^^^"
+ . "..544171f79ec3e50bb5003007e9f4ebb9a7e9fe84";
+my $large_range= "6d02a9e121d037896df9b91ac623c1ab4c98c99a.."
+ . "544171f79ec3e50bb5003007e9f4ebb9a7e9fe8";
+my $with_unknown_range= "96a91e01636d3050d38ae3373a362c7d47a6647e^^^.."
+ . "96a91e01636d3050d38ae3373a362c7d47a6647e";
+foreach my $tuple (
+ [ "--who", $small_range,
+ "James E Keenan, Karl Williamson, Mark Shelor." ],
+ [ "--files", $small_range, files_expected() ],
+ [ "--rank", $large_range, rank_expected()],
+ [ "--rank --percentage", $large_range, rank_percentage_expected()],
+ [ "--rank --percentage --cumulative", $large_range,
+ rank_percentage_cumulative_expected()],
+ [ "--thanks-applied", $large_range, thanks_applied_expected() ],
+ [ "--stats", $large_range, stats_expected() ],
+ [ "--stats --numstat", $large_range, stats_numstat_expected() ],
+ [ "--who" , $with_unknown_range, "Jarkko Hietaniemi.", "(no 'unknown' authors)" ],
+) {
+ my ($arg,$range,$expect, $msg_extra)= @$tuple;
+ my $parsed= `git rev-parse --verify -q $range`;
+ SKIP: {
+ unless ($parsed) {
+ skip "commit range '$range' not available (this happens in CI)", 1;
+ }
+ $msg_extra= $msg_extra ? " $msg_extra" : "";
+ my $cmd= join " ", "$^X ./Porting/updateAUTHORS.pl",
+ $arg, $range;
+ my $result= `$cmd`;
+ is(_clean($result), _clean($expect),"Option '$arg' works as expected$msg_extra")
+ or print STDERR "$cmd\n",$result
+ }
+}
done_testing();
exit 0;
+sub _clean {
+ my ($str)= @_;
+ $str=~s/\s+\z//;
+ $str=~s/[ ]+\n/\n/g;
+ return $str;
+}
+
+sub files_expected {
+ return <<'END_OF_REPORT';
+#Pos | commits | L++ | L-- | L+- | binary_change | Name
+#----+---------+-----+-----+-----+---------------+----------------------------------
+#1 | 1 | 28 | 0 | 28 | 0 | pod/perlfunc.pod
+#2 | 1 | 14 | 4 | 10 | 0 | cpan/Digest-SHA/lib/Digest/SHA.pm
+#3 | 1 | 5 | 5 | 0 | 0 | cpan/Digest-SHA/shasum
+#4 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha64bit.c
+#5 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha64bit.h
+#6 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha.c
+#7 | 1 | 3 | 3 | 0 | 0 | cpan/Digest-SHA/src/sha.h
+#8 | 1 | 1 | 1 | 0 | 0 | Porting/Maintainers.pl
+#9 | 1 | 1 | 0 | 1 | 0 | AUTHORS
+END_OF_REPORT
+}
+
+sub rank_expected {
+ return <<'END_OF_REPORT';
+#Pos | Authored | Name
+#----+----------+-----------------
+#1 | 40 | Karl Williamson
+#2 | 32 | Yves Orton
+#3 | 8 | Paul Evans
+#4 | 6 | James E Keenan
+#5 | 4 | Elvin Aslanov
+#6 | 3 | Richard Leach
+#7 | 3 | Tony Cook
+#8 | 2 | Nicholas Clark
+#9 | 1 | Dan Kogai
+#10 | 1 | David Golden
+#11 | 1 | Graham Knop
+#12 | 1 | Mark Shelor
+#13 | 1 | Tomasz Konojacki
+END_OF_REPORT
+}
+
+sub rank_percentage_expected {
+ return <<'END_OF_REPORT';
+#Pos | %Authored | Name
+#----+-----------+-----------------
+#1 | 38.83 | Karl Williamson
+#2 | 31.07 | Yves Orton
+#3 | 7.77 | Paul Evans
+#4 | 5.83 | James E Keenan
+#5 | 3.88 | Elvin Aslanov
+#6 | 2.91 | Richard Leach
+#7 | 2.91 | Tony Cook
+#8 | 1.94 | Nicholas Clark
+#9 | 0.97 | Dan Kogai
+#10 | 0.97 | David Golden
+#11 | 0.97 | Graham Knop
+#12 | 0.97 | Mark Shelor
+#13 | 0.97 | Tomasz Konojacki
+END_OF_REPORT
+}
+
+sub rank_percentage_cumulative_expected {
+ return <<'END_OF_REPORT';
+#Pos | %Authored | Name
+#----+-----------+-----------------
+#1 | 38.83 | Karl Williamson
+#2 | 69.90 | Yves Orton
+#3 | 77.67 | Paul Evans
+#4 | 83.50 | James E Keenan
+#5 | 87.38 | Elvin Aslanov
+#6 | 90.29 | Richard Leach
+#7 | 93.20 | Tony Cook
+#8 | 95.15 | Nicholas Clark
+#9 | 96.12 | Dan Kogai
+#10 | 97.09 | David Golden
+#11 | 98.06 | Graham Knop
+#12 | 99.03 | Mark Shelor
+#13 | 100.00 | Tomasz Konojacki
+END_OF_REPORT
+}
+
+sub thanks_applied_expected {
+ return <<'END_OF_REPORT';
+#Pos | Applied | Name
+#----+---------+----------------
+#1 | 7 | Karl Williamson
+#2 | 4 | James E Keenan
+END_OF_REPORT
+}
+
+sub stats_expected {
+ return <<'END_OF_REPORT';
+#Pos | Authored | Applied | Committed | Name
+#----+----------+---------+-----------+-----------------
+#1 | 40 | 7 | 47 | Karl Williamson
+#2 | 32 | 0 | 31 | Yves Orton
+#3 | 8 | 0 | 8 | Paul Evans
+#4 | 6 | 4 | 10 | James E Keenan
+#5 | 4 | 0 | 1 | Elvin Aslanov
+#6 | 3 | 0 | 3 | Tony Cook
+#7 | 3 | 0 | 0 | Richard Leach
+#8 | 2 | 0 | 2 | Nicholas Clark
+#9 | 1 | 0 | 1 | Tomasz Konojacki
+#10 | 1 | 0 | 0 | Dan Kogai
+#11 | 1 | 0 | 0 | David Golden
+#12 | 1 | 0 | 0 | Graham Knop
+#13 | 1 | 0 | 0 | Mark Shelor
+END_OF_REPORT
+}
+
+sub stats_numstat_expected {
+ return <<'END_OF_REPORT';
+#Pos | Authored | Applied | Committed | NFiles | L++ | L-- | L+- | Name
+#----+----------+---------+-----------+--------+------+------+------+-----------------
+#1 | 40 | 7 | 47 | 14 | 1179 | 874 | 305 | Karl Williamson
+#2 | 32 | 0 | 31 | 25 | 2547 | 1481 | 1066 | Yves Orton
+#3 | 8 | 0 | 8 | 15 | 161 | 102 | 59 | Paul Evans
+#4 | 6 | 4 | 10 | 4 | 44 | 11 | 33 | James E Keenan
+#5 | 4 | 0 | 1 | 4 | 16 | 13 | 3 | Elvin Aslanov
+#6 | 3 | 0 | 3 | 7 | 8 | 7 | 1 | Tony Cook
+#7 | 3 | 0 | 0 | 13 | 75 | 51 | 24 | Richard Leach
+#8 | 2 | 0 | 2 | 2 | 24 | 1 | 23 | Nicholas Clark
+#9 | 1 | 0 | 1 | 2 | 21 | 15 | 6 | Tomasz Konojacki
+#10 | 1 | 0 | 0 | 8 | 33 | 22 | 11 | Mark Shelor
+#11 | 1 | 0 | 0 | 5 | 93 | 7 | 86 | Graham Knop
+#12 | 1 | 0 | 0 | 4 | 9 | 4 | 5 | Dan Kogai
+#13 | 1 | 0 | 0 | 2 | 19 | 6 | 13 | David Golden
+END_OF_REPORT
+}