Bump Sub::Uplevel dep - too much breaks on <= 0.18
[dbsrgits/DBIx-Class-Historic.git] / xt / dist / authors.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3440100b 3use warnings;
4use strict;
5
6use Test::More;
7use Config;
8use File::Spec;
9
10my @known_authors = do {
11 # according to #p5p this is how one safely reads random unicode
12 # this set of boilerplate is insane... wasn't perl unicode-king...?
13 no warnings 'once';
14 require Encode;
15 require PerlIO::encoding;
16 local $PerlIO::encoding::fallback = Encode::FB_CROAK();
17
18 open (my $fh, '<:encoding(UTF-8)', 'AUTHORS') or die "Unable to open AUTHORS - can't happen: $!\n";
19 map { chomp; ( ( ! $_ or $_ =~ /^\s*\#/ ) ? () : $_ ) } <$fh>;
20
21} or die "Known AUTHORS file seems empty... can't happen...";
22
23is_deeply (
f06eb015 24 [ grep { /^\s/ or /\s\s/ } @known_authors ],
3440100b 25 [],
f06eb015 26 "No entries with leading or doubled space",
27);
28
29is_deeply (
30 [ grep { / \:[^\s\/] /x or /^ [^:]*? \s+ \: /x } @known_authors ],
31 [],
32 "No entries with malformed nicks",
3440100b 33);
34
35is_deeply (
36 \@known_authors,
37 [ sort { lc $a cmp lc $b } @known_authors ],
38 'Author list is case-insensitively sorted'
39);
40
41my $email_re = qr/( \< [^\<\>]+ \> ) $/x;
42
245e3f5d 43my %known_authors;
3440100b 44for (@known_authors) {
45 my ($name_email) = m/ ^ (?: [^\:]+ \: \s )? (.+) /x;
46 my ($email) = $name_email =~ $email_re;
47
245e3f5d 48 fail "Duplicate found: $name_email" if (
3440100b 49 $known_authors{$name_email}++
50 or
51 ( $email and $known_authors{$email}++ )
245e3f5d 52 );
3440100b 53}
54
3440100b 55# augh taint mode
56if (length $ENV{PATH}) {
57 ( $ENV{PATH} ) = join ( $Config{path_sep},
58 map { length($_) ? File::Spec->rel2abs($_) : () }
59 split /\Q$Config{path_sep}/, $ENV{PATH}
60 ) =~ /\A(.+)\z/;
61}
62
606ff399 63# no git-check when smoking a PR
64if (
65 (
66 ! $ENV{TRAVIS_PULL_REQUEST}
67 or
68 $ENV{TRAVIS_PULL_REQUEST} eq "false"
69 )
70 and
71 -d '.git'
3440100b 72) {
606ff399 73
74 binmode (Test::More->builder->$_, ':utf8') for qw/output failure_output todo_output/;
75
76 # this may fail - not every system has git
77 for (
78 map
79 { my ($gitname) = m/^ \s* \d+ \s* (.+?) \s* $/mx; utf8::decode($gitname); $gitname }
80 qx( git shortlog -e -s )
81 ) {
3440100b 82 my ($eml) = $_ =~ $email_re;
83
606ff399 84 ok $known_authors{$eml},
85 "Commit author '$_' (from .mailmap-aware `git shortlog -e -s`) reflected in ./AUTHORS";
3440100b 86 }
87}
88
89done_testing;