summaryrefslogtreecommitdiff
path: root/cpan/Module-Build/t/metadata2.t
blob: a0fdd604d18238d22ae3311c944002f61ce36053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/perl -w

use strict;
use lib 't/lib';
use MBTest tests => 18;

blib_load('Module::Build');
blib_load('Module::Build::ConfigData');

use DistGen;


############################## ACTION distmeta works without a MANIFEST file

SKIP: {
  skip( 'YAML_support feature is not enabled', 4 )
      unless Module::Build::ConfigData->feature('YAML_support');

  my $dist = DistGen->new( no_manifest => 1 )->chdir_in->regen;

  ok ! -e 'MANIFEST';

  my $mb;
  stderr_of( sub { $mb = Module::Build->new_from_context } );

  my $out;
  $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
  is $@, '';

  like $out, qr/Nothing to enter for 'provides'/;

  ok -e 'META.yml';

}


############################## Check generation of README file

# TODO: We need to test faking the absence of Pod::Readme when present
#       so Pod::Text will be used. Also fake the absence of both to
#       test that we fail gracefully.

my $provides; # Used a bunch of times below

my $pod_text = <<'---';
=pod

=head1 NAME

Simple - A simple module

=head1 AUTHOR

Simple Simon <simon@simple.sim>

=cut
---

my $dist = DistGen->new->chdir_in;

$dist->change_build_pl
({
    module_name         => $dist->name,
    dist_version        => '3.14159265',
    license             => 'perl',
    create_readme       => 1,
});

# .pm File with pod
#

$dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
package Simple;
$VERSION = '1.23';
---
$dist->regen( clean => 1 );
ok( -e "lib/Simple.pm", "Creating Simple.pm" );
my $mb = Module::Build->new_from_context;
$mb->do_create_readme;
like( slurp("README"), qr/NAME/,
    "Generating README from .pm");
is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
    "Extracting AUTHOR from .pm");
is( $mb->dist_abstract, "A simple module",
    "Extracting abstract from .pm");

# .pm File with pod in separate file
#

$dist->change_file( 'lib/Simple.pm', <<'---');
package Simple;
$VERSION = '1.23';
---
$dist->change_file( 'lib/Simple.pod', $pod_text );
$dist->regen( clean => 1 );

ok( -e "lib/Simple.pm", "Creating Simple.pm" );
ok( -e "lib/Simple.pod", "Creating Simple.pod" );
$mb = Module::Build->new_from_context;
$mb->do_create_readme;
like( slurp("README"), qr/NAME/, "Generating README from .pod");
is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
    "Extracting AUTHOR from .pod");
is( $mb->dist_abstract, "A simple module",
    "Extracting abstract from .pod");

# .pm File with pod and separate pod file
#

$dist->change_file( 'lib/Simple.pm', <<'---' );
package Simple;
$VERSION = '1.23';

=pod

=head1 DONT USE THIS FILE FOR POD

=cut
---
$dist->change_file( 'lib/Simple.pod', $pod_text );
$dist->regen( clean => 1 );
ok( -e "lib/Simple.pm", "Creating Simple.pm" );
ok( -e "lib/Simple.pod", "Creating Simple.pod" );
$mb = Module::Build->new_from_context;
$mb->do_create_readme;
like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
    "Extracting AUTHOR from .pod over .pm");
is( $mb->dist_abstract, "A simple module",
    "Extracting abstract from .pod over .pm");