Commit | Line | Data |
---|---|---|
f0bcc49a NC |
1 | #!./perl -w |
2 | ||
3 | # What does this test? | |
4 | # This uses Porting/checkAUTHORS.pl to check that any pending commit isn't | |
5 | # about to break t/porting/authors.t | |
6 | # | |
7 | # Why do we test this? | |
8 | # t/porting/authors.t checks that the AUTHORS file is up to date, accounting | |
9 | # for the "Author:" of every commit. However, any pending changes can't be | |
10 | # tested, which leaves a gotcha - "make test" can pass, one then commits | |
11 | # the passing code, pushes it uptream, and tests fail. So this test attempts | |
12 | # to spot that problem before it happens, where it can. | |
13 | # | |
14 | # It's broken - how do I fix it? | |
15 | # It will fail if you're in a git checkout, have uncommitted changes, and the | |
16 | # e-mail address that your commit will default to is in AUTHORS, or the list | |
17 | # of author aliases in Porting/checkAUTHORS.pl. So one of | |
18 | # a) reset your pending changes | |
19 | # b) change your git config user.email to the previously-known e-mail address | |
20 | # c) add yourself to AUTHORS | |
21 | # d) add an alias to Porting/checkAUTHORS.pl | |
22 | ||
23 | BEGIN { | |
24 | @INC = '..' if -f '../TestInit.pm'; | |
25 | } | |
ac976f88 | 26 | use TestInit qw(T); # T is chdir to the top level |
f0bcc49a | 27 | use strict; |
8d85448a | 28 | use File::Spec; |
f0bcc49a NC |
29 | |
30 | require 't/test.pl'; | |
31 | find_git_or_skip('all'); | |
32 | ||
8d85448a | 33 | my $devnull = File::Spec->devnull; |
f0bcc49a | 34 | my $changes; |
8d85448a | 35 | foreach (`git status --porcelain 2>$devnull`) { |
f0bcc49a NC |
36 | next if /^\?\?/; |
37 | ++$changes; | |
38 | last; | |
39 | } | |
40 | ||
41 | skip_all("No pending changes (or git status --porcelain doesn't work here)") | |
42 | unless $changes; | |
43 | ||
44 | sub get { | |
45 | my $key = shift; | |
46 | my $value = `git config --get user.$key`; | |
47 | unless (defined $value && $value =~ /\S/) { | |
ce2dc92a | 48 | skip_all("git config --get user.$key returned nought"); |
f0bcc49a NC |
49 | } |
50 | chomp $value; | |
51 | return $value; | |
52 | } | |
53 | ||
54 | my $email = get('email'); | |
55 | my $name = get('name'); | |
56 | ||
57 | open my $fh, '|-', "$^X Porting/checkAUTHORS.pl --tap -" | |
58 | or die $!; | |
59 | print $fh "Author: $name <$email>\n"; | |
60 | close $fh or die $!; |