This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge branch 'vincent/rvalue_stmt_given' into blead
[perl5.git] / cpan / Module-Build / t / metadata2.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib 't/lib';
5 use MBTest tests => 18;
6
7 blib_load('Module::Build');
8 blib_load('Module::Build::ConfigData');
9
10 use DistGen;
11
12
13 ############################## ACTION distmeta works without a MANIFEST file
14
15 SKIP: {
16   skip( 'YAML_support feature is not enabled', 4 )
17       unless Module::Build::ConfigData->feature('YAML_support');
18
19   my $dist = DistGen->new( no_manifest => 1 )->chdir_in->regen;
20
21   ok ! -e 'MANIFEST';
22
23   my $mb;
24   stderr_of( sub { $mb = Module::Build->new_from_context } );
25
26   my $out;
27   $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
28   is $@, '';
29
30   like $out, qr/Nothing to enter for 'provides'/;
31
32   ok -e 'META.yml';
33
34 }
35
36
37 ############################## Check generation of README file
38
39 # TODO: We need to test faking the absence of Pod::Readme when present
40 #       so Pod::Text will be used. Also fake the absence of both to
41 #       test that we fail gracefully.
42
43 my $provides; # Used a bunch of times below
44
45 my $pod_text = <<'---';
46 =pod
47
48 =head1 NAME
49
50 Simple - A simple module
51
52 =head1 AUTHOR
53
54 Simple Simon <simon@simple.sim>
55
56 =cut
57 ---
58
59 my $dist = DistGen->new->chdir_in;
60
61 $dist->change_build_pl
62 ({
63     module_name         => $dist->name,
64     dist_version        => '3.14159265',
65     license             => 'perl',
66     create_readme       => 1,
67 });
68
69 # .pm File with pod
70 #
71
72 $dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
73 package Simple;
74 $VERSION = '1.23';
75 ---
76 $dist->regen( clean => 1 );
77 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
78 my $mb = Module::Build->new_from_context;
79 $mb->do_create_readme;
80 like( slurp("README"), qr/NAME/,
81     "Generating README from .pm");
82 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
83     "Extracting AUTHOR from .pm");
84 is( $mb->dist_abstract, "A simple module",
85     "Extracting abstract from .pm");
86
87 # .pm File with pod in separate file
88 #
89
90 $dist->change_file( 'lib/Simple.pm', <<'---');
91 package Simple;
92 $VERSION = '1.23';
93 ---
94 $dist->change_file( 'lib/Simple.pod', $pod_text );
95 $dist->regen( clean => 1 );
96
97 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
98 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
99 $mb = Module::Build->new_from_context;
100 $mb->do_create_readme;
101 like( slurp("README"), qr/NAME/, "Generating README from .pod");
102 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
103     "Extracting AUTHOR from .pod");
104 is( $mb->dist_abstract, "A simple module",
105     "Extracting abstract from .pod");
106
107 # .pm File with pod and separate pod file
108 #
109
110 $dist->change_file( 'lib/Simple.pm', <<'---' );
111 package Simple;
112 $VERSION = '1.23';
113
114 =pod
115
116 =head1 DONT USE THIS FILE FOR POD
117
118 =cut
119 ---
120 $dist->change_file( 'lib/Simple.pod', $pod_text );
121 $dist->regen( clean => 1 );
122 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
123 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
124 $mb = Module::Build->new_from_context;
125 $mb->do_create_readme;
126 like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
127 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
128     "Extracting AUTHOR from .pod over .pm");
129 is( $mb->dist_abstract, "A simple module",
130     "Extracting abstract from .pod over .pm");
131