summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-02-15 17:26:53 +0100
committerNicholas Clark <nick@ccl4.org>2012-02-15 17:26:53 +0100
commit6985c285ff695af247365814d0da21ff2537429b (patch)
tree8afa7efee81371554a83c33bbaaa1fb493e232d8
parent2865a99c0e05bf856a9a962f2c08a8beb397d695 (diff)
downloadperl-smoke-me/check-authors.tar.gz
Add t/porting/pending-author.t, fixing a limitation of t/porting/authors.tsmoke-me/check-authors
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.
-rw-r--r--MANIFEST1
-rw-r--r--pod/perldelta.pod7
-rw-r--r--t/porting/pending-author.t60
3 files changed, 67 insertions, 1 deletions
diff --git a/MANIFEST b/MANIFEST
index 903cda907b..ddcac2a2b1 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5373,6 +5373,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/podcheck.t Test the POD of shipped modules is well formed
t/porting/pod_rules.t Check that various pod lists are consistent
t/porting/regen.t Check that regen.pl doesn't need running
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 9920e1e52a..a4c15a6bf2 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -551,7 +551,12 @@ that they represent may be covered elsewhere.
=item *
-XXX
+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 *
diff --git a/t/porting/pending-author.t b/t/porting/pending-author.t
new file mode 100644
index 0000000000..6bc392b35c
--- /dev/null
+++ b/t/porting/pending-author.t
@@ -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 $!;