File: pending-author.t

package info (click to toggle)
perl 5.20.2-3%2Bdeb8u11
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 102,964 kB
  • sloc: perl: 555,553; ansic: 214,041; sh: 38,121; pascal: 8,783; cpp: 3,895; makefile: 2,393; xml: 2,325; yacc: 1,741
file content (60 lines) | stat: -rw-r--r-- 1,795 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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); # T is chdir to the top level
use strict;
use File::Spec;

require 't/test.pl';
find_git_or_skip('all');

my $devnull = File::Spec->devnull;
my $changes;
foreach (`git status --porcelain 2>$devnull`) {
    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/) {
	skip_all("git config --get user.$key returned nought");
    }
    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 $!;