File: podversion.t

package info (click to toggle)
libdist-zilla-perl 6.032-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,928 kB
  • sloc: perl: 7,275; makefile: 4; sh: 1
file content (137 lines) | stat: -rw-r--r-- 1,957 bytes parent folder | download | duplicates (5)
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
132
133
134
135
136
137
use strict;
use warnings;
use Test::More 0.88;

use autodie;
use Test::DZil;

my $with_place_for_pod = '

package DZT::WPFP;

=head1 NAME

DZT::WPFP - with place for pod!

=cut

sub foo { }

1;
';

my $with_version = '

package DZT::WVer;

=head1 NAME

DZT::WVer - version in pod!

=head1 VERSION

version 1.234

=cut

sub foo { }

1;
';

my $with_multi_line_abstract = '

package DZT::MLA;

=head1 NAME

DZT::MLA - This abstract spans
multiple lines.

=cut

sub foo { }

1;
';

my $script = '
#!/usr/bin/perl

=head1 NAME

script.pl - a podded script!

=cut

print "hello world\n";
';

my $tzil = Builder->from_config(
  { dist_root => 'corpus/dist/DZT' },
  {
    add_files => {
      'source/lib/DZT/WPFP.pm' => $with_place_for_pod,
      'source/lib/DZT/WVer.pm' => $with_version,
      'source/lib/DZT/MLA.pm' => $with_multi_line_abstract,
      'source/bin/script.pl'   => $script,
      'source/dist.ini' => simple_ini('GatherDir', 'PodVersion', 'ExecDir'),
    },
  },
);

$tzil->build;

my $want = <<'END_POD';
=head1 VERSION

version 0.001

=cut
END_POD

my $want_mla = <<'END_POD';
=head1 NAME

DZT::MLA - This abstract spans
multiple lines.

=head1 VERSION

version 0.001

=cut
END_POD

my $dzt_sample = $tzil->slurp_file('build/lib/DZT/Sample.pm');
ok(
  index($dzt_sample, $want) == -1,
  "we didn't add version pod to Sample; it has no NAME",
);

my $dzt_wpfp = $tzil->slurp_file('build/lib/DZT/WPFP.pm');
ok(
  index($dzt_wpfp, $want) > 0,
  "we did add version pod to WPFP",
);

my $dzt_wver = $tzil->slurp_file('build/lib/DZT/WVer.pm');
ok(
  index($dzt_wver, $want) == -1,
  "we didn't add version pod to WVer; it has one already",
);

my $dzt_mla = $tzil->slurp_file('build/lib/DZT/MLA.pm');
ok(
  index($dzt_mla, $want_mla) > 0,
  "we properly skipped over multi-line abstract",
);

my $dzt_script = $tzil->slurp_file('build/bin/script.pl');
ok(
  index($dzt_script, $want) > 0,
  "we did add version pod to script",
);

done_testing;