4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 20;
7 use_ok 'Module::Build';
8 ensure_blib('Module::Build');
10 my $tmp = MBTest->tmpdir;
12 use Module::Build::ConfigData;
16 ############################## ACTION distmeta works without a MANIFEST file
19 skip( 'YAML_support feature is not enabled', 4 )
20 unless Module::Build::ConfigData->feature('YAML_support');
22 my $dist = DistGen->new( dir => $tmp, skip_manifest => 1 );
29 my $mb = Module::Build->new_from_context;
32 $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
35 like $out, qr/Nothing to enter for 'provides'/;
43 ############################## Check generation of README file
45 # TODO: We need to test faking the absence of Pod::Readme when present
46 # so Pod::Text will be used. Also fake the absence of both to
47 # test that we fail gracefully.
49 my $provides; # Used a bunch of times below
51 my $pod_text = <<'---';
56 Simple - A simple module
60 Simple Simon <simon@simple.sim>
65 my $dist = DistGen->new( dir => $tmp );
67 $dist->change_build_pl
69 module_name => $dist->name,
70 dist_version => '3.14159265',
82 $dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
86 $dist->regen( clean => 1 );
87 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
88 my $mb = Module::Build->new_from_context;
89 $mb->do_create_readme;
90 like( slurp("README"), qr/NAME/,
91 "Generating README from .pm");
92 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
93 "Extracting AUTHOR from .pm");
94 is( $mb->dist_abstract, "A simple module",
95 "Extracting abstract from .pm");
97 # .pm File with pod in separate file
100 $dist->change_file( 'lib/Simple.pm', <<'---');
104 $dist->change_file( 'lib/Simple.pod', $pod_text );
105 $dist->regen( clean => 1 );
107 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
108 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
109 $mb = Module::Build->new_from_context;
110 $mb->do_create_readme;
111 like( slurp("README"), qr/NAME/, "Generating README from .pod");
112 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
113 "Extracting AUTHOR from .pod");
114 is( $mb->dist_abstract, "A simple module",
115 "Extracting abstract from .pod");
117 # .pm File with pod and separate pod file
120 $dist->change_file( 'lib/Simple.pm', <<'---' );
126 =head1 DONT USE THIS FILE FOR POD
130 $dist->change_file( 'lib/Simple.pod', $pod_text );
131 $dist->regen( clean => 1 );
132 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
133 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
134 $mb = Module::Build->new_from_context;
135 $mb->do_create_readme;
136 like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
137 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
138 "Extracting AUTHOR from .pod over .pm");
139 is( $mb->dist_abstract, "A simple module",
140 "Extracting abstract from .pod over .pm");
143 ############################################################