This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix O_CREAT without O_TRUNC in cpan/autodie/t/utf8_open.t
[perl5.git] / t / porting / pending-author.t
CommitLineData
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
23BEGIN {
24 @INC = '..' if -f '../TestInit.pm';
25}
ac976f88 26use TestInit qw(T); # T is chdir to the top level
f0bcc49a
NC
27use strict;
28
29require 't/test.pl';
30find_git_or_skip('all');
31
32my $changes;
33foreach (`git status --porcelain 2>/dev/null`) {
34 next if /^\?\?/;
35 ++$changes;
36 last;
37}
38
39skip_all("No pending changes (or git status --porcelain doesn't work here)")
40 unless $changes;
41
42sub get {
43 my $key = shift;
44 my $value = `git config --get user.$key`;
45 unless (defined $value && $value =~ /\S/) {
ce2dc92a 46 skip_all("git config --get user.$key returned nought");
f0bcc49a
NC
47 }
48 chomp $value;
49 return $value;
50}
51
52my $email = get('email');
53my $name = get('name');
54
55open my $fh, '|-', "$^X Porting/checkAUTHORS.pl --tap -"
56 or die $!;
57print $fh "Author: $name <$email>\n";
58close $fh or die $!;