xref: /openbsd-src/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/several_authors.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#!/usr/bin/perl -w
2
3# This is a test checking various aspects of the optional argument
4# MIN_PERL_VERSION to WriteMakefile.
5
6BEGIN {
7    unshift @INC, 't/lib';
8}
9
10use strict;
11use Config;
12use Test::More
13    $ENV{PERL_CORE} && $Config{'usecrosscompile'}
14    ? (skip_all => "no toolchain installed when cross-compiling")
15    : (tests => 20);
16
17use TieOut;
18use MakeMaker::Test::Utils;
19use MakeMaker::Test::Setup::SAS;
20use File::Path;
21
22use ExtUtils::MakeMaker;
23
24# avoid environment variables interfering with our make runs
25delete @ENV{qw(LIB MAKEFLAGS)};
26
27my $perl     = which_perl();
28my $make     = make_run();
29my $makefile = makefile_name();
30
31chdir 't';
32
33perl_lib();
34
35ok( setup_recurs(), 'setup' );
36END {
37    ok( chdir(File::Spec->updir), 'leaving dir' );
38    ok( teardown_recurs(), 'teardown' );
39}
40
41ok( chdir $MakeMaker::Test::Setup::SAS::dirname, "entering dir $MakeMaker::Test::Setup::SAS::dirname" ) ||
42    diag("chdir failed: $!");
43
44note "argument verification"; {
45    my $stdout = tie *STDOUT, 'TieOut';
46    ok( $stdout, 'capturing stdout' );
47    my $warnings = '';
48    local $SIG{__WARN__} = sub {
49        $warnings .= join '', @_;
50    };
51
52    eval {
53        WriteMakefile(
54            NAME             => 'Multiple::Authors',
55            AUTHOR           => ['John Doe <jd@example.com>', 'Jane Doe <jd@example.com>'],
56        );
57    };
58    is( $warnings, '', 'arrayref in AUTHOR does not trigger a warning' );
59    is( $@, '',        '  nor a hard failure' );
60
61}
62
63
64note "argument verification via CONFIGURE"; {
65    my $stdout = tie *STDOUT, 'TieOut';
66    ok( $stdout, 'capturing stdout' );
67    my $warnings = '';
68    local $SIG{__WARN__} = sub {
69        $warnings .= join '', @_;
70    };
71
72    eval {
73        WriteMakefile(
74            NAME             => 'Multiple::Authors',
75            CONFIGURE => sub {
76               return {AUTHOR => 'John Doe <jd@example.com>',};
77            },
78        );
79    };
80    is( $warnings, '', 'scalar in AUTHOR inside CONFIGURE does not trigger a warning' );
81    is( $@, '',        '  nor a hard failure' );
82
83}
84
85
86note "generated files verification"; {
87    unlink $makefile;
88    my @mpl_out = run(qq{$perl Makefile.PL});
89    END { unlink $makefile, makefile_backup() }
90
91    cmp_ok( $?, '==', 0, 'Makefile.PL exiting normally' ) || diag(@mpl_out);
92    ok( -e $makefile, 'Makefile present' );
93}
94
95
96note "ppd output"; {
97    my $ppd_file = 'Multiple-Authors.ppd';
98    my @make_out = run(qq{$make ppd});
99    END { unlink $ppd_file }
100
101    cmp_ok( $?, '==', 0,    'Make ppd exiting normally' ) || diag(@make_out);
102
103    my $ppd_html = slurp($ppd_file);
104    ok( defined($ppd_html), '  .ppd file present' );
105
106    like( $ppd_html, qr{John Doe &lt;jd\@example.com&gt;, Jane Doe &lt;jd\@example.com&gt;},
107                            '  .ppd file content good' );
108}
109
110
111note "META.yml output"; {
112    my $distdir  = 'Multiple-Authors-0.05';
113    $distdir =~ s{\.}{_}g if $Is_VMS;
114
115    my $meta_yml = "$distdir/META.yml";
116    my $meta_json = "$distdir/META.json";
117    my @make_out    = run(qq{$make metafile});
118    END { rmtree $distdir }
119
120    cmp_ok( $?, '==', 0, 'Make metafile exiting normally' ) || diag(@make_out);
121
122    for my $case (
123        ['META.yml', $meta_yml],
124        ['META.json', $meta_json],
125    ) {
126        my ($label, $meta_name) = @$case;
127        ok(
128          my $obj = eval {
129            CPAN::Meta->load_file($meta_name, {lazy_validation => 0})
130          },
131          "$label validates"
132        );
133        is_deeply( [ $obj->authors ],
134          [
135            q{John Doe <jd@example.com>},
136            q{Jane Doe <jd@example.com>},
137          ],
138          "$label content good"
139        );
140    }
141}
142