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