4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 18;
9 my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
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 );
25 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
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'/;
39 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
44 ############################## Check generation of README file
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.
50 my $provides; # Used a bunch of times below
52 my $pod_text = <<'---';
57 Simple - A simple module
61 Simple Simon <simon@simple.sim>
66 my $dist = DistGen->new( dir => $tmp );
68 $dist->change_file( 'Build.PL', <<"---" );
70 my \$builder = Module::Build->new(
71 module_name => '@{[$dist->name]}',
72 dist_version => '3.14159265',
77 \$builder->create_build_script();
81 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
87 $dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
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");
102 # .pm File with pod in separate file
105 $dist->change_file( 'lib/Simple.pm', <<'---');
109 $dist->change_file( 'lib/Simple.pod', $pod_text );
110 $dist->regen( clean => 1 );
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");
122 # .pm File with pod and separate pod file
125 $dist->change_file( 'lib/Simple.pm', <<'---' );
131 =head1 DONT USE THIS FILE FOR POD
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");
148 ############################################################
150 chdir( $cwd ) or die "Can't chdir to '$cwd': $!";