3 # This is a test checking various aspects of the optional argument
4 # MIN_PERL_VERSION to WriteMakefile.
13 use MakeMaker::Test::Utils;
17 !MM->can_run(make()) && $ENV{PERL_CORE} && $Config{'usecrosscompile'}
18 ? (skip_all => "cross-compiling and make not available")
21 use File::Temp qw[tempdir];
23 use ExtUtils::MakeMaker;
24 my $CM = eval { require CPAN::Meta; };
26 my $DIRNAME = 'Multiple-Authors';
28 'Makefile.PL' => <<'END',
29 use ExtUtils::MakeMaker;
31 NAME => 'Multiple::Authors',
32 AUTHOR => ['John Doe <jd@example.com>', 'Jane Doe <jd@example.com>'],
33 VERSION_FROM => 'lib/Multiple/Authors.pm',
34 PREREQ_PM => { strict => 0 },
38 'lib/Multiple/Authors.pm' => <<'END',
39 package Multiple::Authors;
45 Multiple::Authors - several authors
54 # avoid environment variables interfering with our make runs
55 delete @ENV{qw(LIB MAKEFLAGS PERL_CORE)};
57 my $perl = which_perl();
58 my $make = make_run();
59 my $makefile = makefile_name();
62 perl_lib; # sets $ENV{PERL5LIB} relative to t/
64 my $tmpdir = tempdir( DIR => '../t', CLEANUP => 1 );
65 use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
68 hash2files($DIRNAME, \%FILES);
70 ok( chdir(File::Spec->updir), 'leaving dir' );
71 ok( rmtree($DIRNAME), 'teardown' );
74 ok( chdir $DIRNAME, "entering dir $DIRNAME" ) ||
75 diag("chdir failed: $!");
77 note "argument verification"; {
78 my $stdout = tie *STDOUT, 'TieOut';
79 ok( $stdout, 'capturing stdout' );
81 local $SIG{__WARN__} = sub {
82 $warnings .= join '', @_;
87 NAME => 'Multiple::Authors',
88 AUTHOR => ['John Doe <jd@example.com>', 'Jane Doe <jd@example.com>'],
91 is( $warnings, '', 'arrayref in AUTHOR does not trigger a warning' );
92 is( $@, '', ' nor a hard failure' );
97 note "argument verification via CONFIGURE"; {
98 my $stdout = tie *STDOUT, 'TieOut';
99 ok( $stdout, 'capturing stdout' );
101 local $SIG{__WARN__} = sub {
102 $warnings .= join '', @_;
107 NAME => 'Multiple::Authors',
109 return {AUTHOR => 'John Doe <jd@example.com>',};
113 is( $warnings, '', 'scalar in AUTHOR inside CONFIGURE does not trigger a warning' );
114 is( $@, '', ' nor a hard failure' );
119 note "generated files verification"; {
121 my @mpl_out = run(qq{$perl Makefile.PL});
122 END { unlink $makefile, makefile_backup() }
124 cmp_ok( $?, '==', 0, 'Makefile.PL exiting normally' ) || diag(@mpl_out);
125 ok( -e $makefile, 'Makefile present' );
130 my $ppd_file = 'Multiple-Authors.ppd';
131 my @make_out = run(qq{$make ppd});
132 END { unlink $ppd_file }
134 cmp_ok( $?, '==', 0, 'Make ppd exiting normally' ) || diag(@make_out);
136 my $ppd_html = slurp($ppd_file);
137 ok( defined($ppd_html), ' .ppd file present' );
139 like( $ppd_html, qr{John Doe <jd\@example.com>, Jane Doe <jd\@example.com>},
140 ' .ppd file content good' );
144 note "META.yml output"; SKIP: {
145 skip 'Failed to load CPAN::Meta', 5 unless $CM;
146 my $distdir = 'Multiple-Authors-0.05';
147 $distdir =~ s{\.}{_}g if $Is_VMS;
149 my $meta_yml = "$distdir/META.yml";
150 my $meta_json = "$distdir/META.json";
151 my @make_out = run(qq{$make metafile});
152 END { rmtree $distdir if defined $distdir }
154 cmp_ok( $?, '==', 0, 'Make metafile exiting normally' ) || diag(@make_out);
157 ['META.yml', $meta_yml],
158 ['META.json', $meta_json],
160 my ($label, $meta_name) = @$case;
163 CPAN::Meta->load_file($meta_name, {lazy_validation => 0})
167 is_deeply( [ $obj->authors ],
169 q{John Doe <jd@example.com>},
170 q{Jane Doe <jd@example.com>},
172 "$label content good"