This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add t/porting/pending-author.t, fixing a limitation of t/porting/authors.t
authorNicholas Clark <nick@ccl4.org>
Wed, 15 Feb 2012 16:26:53 +0000 (17:26 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 18 Feb 2012 22:20:59 +0000 (23:20 +0100)
t/porting/pending-author.t attempts to avoid the problem of C<make test>
passing 100%, but the subsequent git commit causing F<t/porting/authors.t>
to fail, because it uses a "new" e-mail address.

This test is only run if one is building inside a git checkout, B<and> one
has made local changes. Otherwise it's skipped.

MANIFEST
pod/perldelta.pod
t/porting/pending-author.t [new file with mode: 0644]

index 1853b50..b5268a9 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5375,6 +5375,7 @@ t/porting/globvar.t               Check that globvar.sym is sane
 t/porting/known_pod_issues.dat Data file for porting/podcheck.t
 t/porting/maintainers.t                Test that Porting/Maintainers.pl is up to date
 t/porting/manifest.t           Test that this MANIFEST file is well formed
+t/porting/pending-author.t     Check if any pending commit would break tests
 t/porting/perlfunc.t           Test that Functions_pm.PL can parse perlfunc.pod
 t/porting/podcheck.t           Test the POD of shipped modules is well formed
 t/porting/pod_rules.t          Check that various pod lists are consistent
index 3eec149..aaf6027 100644 (file)
@@ -583,6 +583,15 @@ that they represent may be covered elsewhere.
 
 =item *
 
+F<t/porting/pending-author.t> has been added, to avoid the problem of
+C<make test> passing 100%, but the subsequent git commit causing
+F<t/porting/authors.t> to fail, because it uses a "new" e-mail address.
+
+This test is only run if one is building inside a git checkout, B<and> one
+has made local changes. Otherwise it's skipped.
+
+=item *
+
 F<t/porting/perlfunc.t> has been added, to test that changes to
 F<pod/perlfunc.pod> do not inadvertently break the build of L<Pod::Functions>.
 
diff --git a/t/porting/pending-author.t b/t/porting/pending-author.t
new file mode 100644 (file)
index 0000000..6bc392b
--- /dev/null
@@ -0,0 +1,60 @@
+#!./perl -w
+
+# What does this test?
+# This uses Porting/checkAUTHORS.pl to check that any pending commit isn't
+# about to break t/porting/authors.t
+#
+# Why do we test this?
+# t/porting/authors.t checks that the AUTHORS file is up to date, accounting
+# for the "Author:" of every commit. However, any pending changes can't be
+# tested, which leaves a gotcha - "make test" can pass, one then commits
+# the passing code, pushes it uptream, and tests fail. So this test attempts
+# to spot that problem before it happens, where it can.
+#
+# It's broken - how do I fix it?
+# It will fail if you're in a git checkout, have uncommitted changes, and the
+# e-mail address that your commit will default to is in AUTHORS, or the list
+# of author aliases in Porting/checkAUTHORS.pl. So one of
+# a) reset your pending changes
+# b) change your git config user.email to the previously-known e-mail address
+# c) add yourself to AUTHORS
+# d) add an alias to Porting/checkAUTHORS.pl
+
+BEGIN {
+    @INC = '..' if -f '../TestInit.pm';
+}
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
+use strict;
+
+require 't/test.pl';
+find_git_or_skip('all');
+
+my $changes;
+foreach (`git status --porcelain 2>/dev/null`) {
+    next if /^\?\?/;
+    ++$changes;
+    last;
+}
+
+skip_all("No pending changes (or git status --porcelain doesn't work here)")
+    unless $changes;
+
+sub get {
+    my $key = shift;
+    my $value = `git config --get user.$key`;
+    unless (defined $value && $value =~ /\S/) {
+       plan(1);
+       like($value, qr/\S/, "git config --get user.$key returned a value");
+       exit 1;
+    }
+    chomp $value;
+    return $value;
+}
+
+my $email = get('email');
+my $name = get('name');
+
+open my $fh, '|-', "$^X Porting/checkAUTHORS.pl --tap -"
+    or die $!;
+print $fh "Author: $name <$email>\n";
+close $fh or die $!;