This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update ExtUtils::ParseXS to 2.20_01
[perl5.git] / lib / ExtUtils / t / basic_finish.pl
1 # *NOTE* This is executed by basic.t and is included in both ExtUtils-MakeMaker 
2 # as well as Perlcore. Note also that it is expected to be executed in a do "FILE"
3 # immediately after basic.plt is executed (similarly).
4
5 # It is NOT expected to be executed under ExtUtils-Install alone, and in fact is not
6 # distributed there, however it is expected to be executed under ExtUtils-MakeMaker
7 # and Perl itself.
8
9 my $dist_test_out = run("$make disttest");
10 is( $?, 0, 'disttest' ) || diag($dist_test_out);
11
12 # Test META.yml generation
13 use ExtUtils::Manifest qw(maniread);
14
15 my $distdir  = 'Big-Dummy-0.01';
16 $distdir =~ s/\./_/g if $Is_VMS;
17 my $meta_yml = "$distdir/META.yml";
18
19 ok( !-f 'META.yml',  'META.yml not written to source dir' );
20 ok( -f $meta_yml,    'META.yml written to dist dir' );
21 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
22
23 SKIP: {
24     # META.yml spec 1.4 was added in 0.11
25     skip "Test::YAML::Meta >= 0.11 required", 2
26       unless eval { require Test::YAML::Meta }   and
27              Test::YAML::Meta->VERSION >= 0.11;
28
29     Test::YAML::Meta::meta_spec_ok($meta_yml);
30 }
31
32 ok open META, $meta_yml or diag $!;
33 my $meta = join '', <META>;
34 ok close META;
35
36 is $meta, <<"END";
37 --- #YAML:1.0
38 name:               Big-Dummy
39 version:            0.01
40 abstract:           Try "our" hot dog's
41 author:
42     - Michael G Schwern <schwern\@pobox.com>
43 license:            unknown
44 distribution_type:  module
45 configure_requires:
46     ExtUtils::MakeMaker:  0
47 requires:
48     strict:  0
49 no_index:
50     directory:
51         - t
52         - inc
53 generated_by:       ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
54 meta-spec:
55     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
56     version:  1.4
57 END
58
59 my $manifest = maniread("$distdir/MANIFEST");
60 # VMS is non-case preserving, so we can't know what the MANIFEST will
61 # look like. :(
62 _normalize($manifest);
63 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
64
65
66 # Test NO_META META.yml suppression
67 unlink $meta_yml;
68 ok( !-f $meta_yml,   'META.yml deleted' );
69 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
70 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
71 my $distdir_out = run("$make distdir");
72 is( $?, 0, 'distdir' ) || diag($distdir_out);
73 ok( !-f $meta_yml,   'META.yml generation suppressed by NO_META' );
74
75
76 # Make sure init_dirscan doesn't go into the distdir
77 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
78
79 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
80
81 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
82                                 'init_dirscan skipped distdir') || 
83   diag(@mpl_out);
84
85 # I know we'll get ignored errors from make here, that's ok.
86 # Send STDERR off to oblivion.
87 open(SAVERR, ">&STDERR") or die $!;
88 open(STDERR, ">".File::Spec->devnull) or die $!;
89
90 my $realclean_out = run("$make realclean");
91 is( $?, 0, 'realclean' ) || diag($realclean_out);
92
93 open(STDERR, ">&SAVERR") or die $!;
94 close SAVERR;
95
96
97 sub _normalize {
98     my $hash = shift;
99
100     while(my($k,$v) = each %$hash) {
101         delete $hash->{$k};
102         $hash->{lc $k} = $v;
103     }
104 }