Remove unused Module::Build tests
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / metadata2.t
CommitLineData
bb4e9162 1#!/usr/bin/perl -w
2
3use strict;
4use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5use MBTest tests => 18;
6
7use Cwd ();
8my $cwd = Cwd::cwd;
9my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
10
11use Module::Build;
12use Module::Build::ConfigData;
13use DistGen;
14
15
16############################## ACTION distmeta works without a MANIFEST file
17
18SKIP: {
19 skip( 'YAML_support feature is not enabled', 4 )
20 unless Module::Build::ConfigData->feature('YAML_support');
21
22 my $dist = DistGen->new( dir => $tmp, skip_manifest => 1 );
23 $dist->regen;
24
25 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
26
27 ok ! -e 'MANIFEST';
28
29 my $mb = Module::Build->new_from_context;
30
31 my $out;
32 $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
33 is $@, '';
34
35 like $out, qr/Nothing to enter for 'provides'/;
36
37 ok -e 'META.yml';
38
39 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
40 $dist->remove;
41}
42
43
44############################## Check generation of README file
45
46# TODO: We need to test faking the absence of Pod::Readme when present
47# so Pod::Text will be used. Also fake the absence of both to
48# test that we fail gracefully.
49
50my $provides; # Used a bunch of times below
51
52my $pod_text = <<'---';
53=pod
54
55=head1 NAME
56
57Simple - A simple module
58
59=head1 AUTHOR
60
61Simple Simon <simon@simple.sim>
62
63=cut
64---
65
66my $dist = DistGen->new( dir => $tmp );
67
68$dist->change_file( 'Build.PL', <<"---" );
69use Module::Build;
70my \$builder = Module::Build->new(
71 module_name => '@{[$dist->name]}',
72 dist_version => '3.14159265',
73 license => 'perl',
74 create_readme => 1,
75);
76
77\$builder->create_build_script();
78---
79$dist->regen;
80
81chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
82
83
84# .pm File with pod
85#
86
87$dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
88package Simple;
89$VERSION = '1.23';
90---
91$dist->regen( clean => 1 );
92ok( -e "lib/Simple.pm", "Creating Simple.pm" );
93my $mb = Module::Build->new_from_context;
94$mb->do_create_readme;
95like( slurp("README"), qr/NAME/,
96 "Generating README from .pm");
97is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
98 "Extracting AUTHOR from .pm");
99is( $mb->dist_abstract, "A simple module",
100 "Extracting abstract from .pm");
101
102# .pm File with pod in separate file
103#
104
105$dist->change_file( 'lib/Simple.pm', <<'---');
106package Simple;
107$VERSION = '1.23';
108---
109$dist->change_file( 'lib/Simple.pod', $pod_text );
110$dist->regen( clean => 1 );
111
112ok( -e "lib/Simple.pm", "Creating Simple.pm" );
113ok( -e "lib/Simple.pod", "Creating Simple.pod" );
114$mb = Module::Build->new_from_context;
115$mb->do_create_readme;
116like( slurp("README"), qr/NAME/, "Generating README from .pod");
117is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
118 "Extracting AUTHOR from .pod");
119is( $mb->dist_abstract, "A simple module",
120 "Extracting abstract from .pod");
121
122# .pm File with pod and separate pod file
123#
124
125$dist->change_file( 'lib/Simple.pm', <<'---' );
126package Simple;
127$VERSION = '1.23';
128
129=pod
130
131=head1 DONT USE THIS FILE FOR POD
132
133=cut
134---
135$dist->change_file( 'lib/Simple.pod', $pod_text );
136$dist->regen( clean => 1 );
137ok( -e "lib/Simple.pm", "Creating Simple.pm" );
138ok( -e "lib/Simple.pod", "Creating Simple.pod" );
139$mb = Module::Build->new_from_context;
140$mb->do_create_readme;
141like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
142is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
143 "Extracting AUTHOR from .pod over .pm");
144is( $mb->dist_abstract, "A simple module",
145 "Extracting abstract from .pod over .pm");
146
147
148############################################################
149# cleanup
150chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
151$dist->remove;
152
153use File::Path;
154rmtree( $tmp );