Remove unused Module::Build tests
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / metadata2.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 18;
6
7 use Cwd ();
8 my $cwd = Cwd::cwd;
9 my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
10
11 use Module::Build;
12 use Module::Build::ConfigData;
13 use DistGen;
14
15
16 ############################## ACTION distmeta works without a MANIFEST file
17
18 SKIP: {
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
50 my $provides; # Used a bunch of times below
51
52 my $pod_text = <<'---'; 
53 =pod
54
55 =head1 NAME
56
57 Simple - A simple module 
58
59 =head1 AUTHOR
60
61 Simple Simon <simon@simple.sim>
62
63 =cut
64 ---
65
66 my $dist = DistGen->new( dir => $tmp );
67
68 $dist->change_file( 'Build.PL', <<"---" );
69 use Module::Build;
70 my \$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
81 chdir( $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);
88 package Simple;
89 $VERSION = '1.23';
90 ---
91 $dist->regen( clean => 1 );
92 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
93 my $mb = Module::Build->new_from_context;
94 $mb->do_create_readme;
95 like( slurp("README"), qr/NAME/, 
96     "Generating README from .pm");
97 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>', 
98     "Extracting AUTHOR from .pm");
99 is( $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', <<'---');
106 package Simple;
107 $VERSION = '1.23';
108 ---
109 $dist->change_file( 'lib/Simple.pod', $pod_text );
110 $dist->regen( clean => 1 );
111
112 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
113 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
114 $mb = Module::Build->new_from_context;
115 $mb->do_create_readme;
116 like( slurp("README"), qr/NAME/, "Generating README from .pod");
117 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>', 
118     "Extracting AUTHOR from .pod");
119 is( $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', <<'---' );
126 package 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 );
137 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
138 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
139 $mb = Module::Build->new_from_context;
140 $mb->do_create_readme;
141 like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
142 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
143     "Extracting AUTHOR from .pod over .pm");
144 is( $mb->dist_abstract, "A simple module",
145     "Extracting abstract from .pod over .pm");
146
147
148 ############################################################
149 # cleanup
150 chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
151 $dist->remove;
152
153 use File::Path;
154 rmtree( $tmp );