File: x_cpants.t

package info (click to toggle)
libmodule-cpants-analyse-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 312 kB
  • sloc: perl: 2,192; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,561 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
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Module::CPANTS::TestAnalyse;

test_distribution {
  my ($mca, $dir) = @_;
  write_metayml("$dir/META.yml");
  write_pmfile("$dir/Test.pm");

  my $res = $mca->run;

  ok !$res->{kwalitee}{use_strict}, "use_strict fails correctly";
  ok !$res->{kwalitee}{has_tests}, "has_tests fails correctly";
};

test_distribution {
  my ($mca, $dir) = @_;

  write_pmfile("$dir/Test.pm");
  write_metayml("$dir/META.yml", {
    x_cpants => {ignore => {
      use_strict => 'for some reason',
    }}
  });

  my $res = $mca->run;
  ok $res->{kwalitee}{use_strict}, "use_strict is ignored (and treated as pass)";
  ok $res->{error}{use_strict} && $res->{error}{use_strict} =~ /Module::CPANTS::Analyse::Test/ && $res->{error}{use_strict} =~ /ignored/, "error is not removed and marked as 'ignored'";
  ok !$res->{kwalitee}{has_tests}, "has_tests fails correctly";
};

test_distribution {
  my ($mca, $dir) = @_;

  write_pmfile("$dir/Test.pm");
  write_metayml("$dir/META.yml", {
    x_cpants => {ignore => {
      use_strict => 'for some reason',
      has_tests => 'because I am so lazy',
    }}
  });

  my $res = $mca->run;
  ok $res->{kwalitee}{use_strict}, "use_strict is ignored (and treated as pass)";
  ok $res->{error}{use_strict} && $res->{error}{use_strict} =~ /Module::CPANTS::Analyse::Test/ && $res->{error}{use_strict} =~ /ignored/, "error is not removed and marked as 'ignored'";
  ok !$res->{kwalitee}{has_tests}, "has_tests fails correctly regardless of the x_cpants";
};

done_testing;