File: cpanfile.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 (70 lines) | stat: -rw-r--r-- 1,325 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::More;
use Test::DZil;

use Dist::Zilla::Plugin::CPANFile;

# unfortunately this is a copy from the tested code
my $version = $Dist::Zilla::Plugin::CPANFile::VERSION // '<internal>';

is(
	cpanfile('build/cpanfile') => <<"INI",
# This file is generated by Dist::Zilla::Plugin::CPANFile v$version
# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.

requires "strict" => "0";
requires "warnings" => "0";
INI
	"cpanfile contains requirements"
);

ok(
	cpanfile('build/otherfile' => { filename => 'otherfile' }),
 "non-default filename"
);

is(
  cpanfile('build/cpanfile' => { comment => ["foobar"] }) =>
  <<"INI",
# foobar

requires "strict" => "0";
requires "warnings" => "0";
INI
  "simple comment"
);

is(
  cpanfile('build/cpanfile' => { comment => [ "foo", "bar" ] }),
  <<"INI",
# foo
# bar

requires "strict" => "0";
requires "warnings" => "0";
INI
  "multiline comment"
);

sub cpanfile {
  my $filename = shift;

  my $opts = @_ ? [ map { (CPANFile => $_) } @_ ] : 'CPANFile';

  my $tzil = Builder->from_config(
    { dist_root => 'corpus/dist/DZ1' },
    {
      add_files => {
        'source/dist.ini' => simple_ini(qw< GatherDir AutoPrereqs  >, $opts),
      },
    },
  );

  $tzil->build;

  return $tzil->slurp_file($filename);
}

done_testing;