1use strict;
2BEGIN{ if (not $] < 5.006) { require warnings; warnings->import } }
3
4select(STDERR); $|=1;
5select(STDOUT); $|=1;
6
7use Test::More;
8use t::MockCPANDist;
9use t::Helper;
10use t::Frontend;
11use Config;
12use Probe::Perl;
13use File::Temp;
14
15# Need to have bleadperls pretend to be normal for these tests
16use t::MockPatchlevel;
17
18my $make = $Config{make};
19my $perl = Probe::Perl->find_perl_interpreter();
20$perl = qq{"$perl"};
21my $skipfile = File::Temp->new();
22print {$skipfile} << 'SKIPFILE';
23# comments should be ok
24^JOHNDOE
25Bogus-SkipModule
26SKIPFILE
27
28$skipfile->close;
29
30my %mock_dist_options = (
31    prereq_pm       => {
32        requires => { 'File::Spec' => 0 },
33    },
34    author_id       => "JOHNQP",
35    author_fullname => "John Q. Public",
36);
37
38my @cases = (
39    {
40        label => "dist *not* in",
41        pretty_id => "JOHNQP/Bogus-Module-1.23.tar.gz",
42        name => "t-Fail",
43        version => 1.23,
44        grade => "fail",
45        phase => "test",
46        command => "$perl Makefile.PL",
47        will_send => 1,
48    },
49    {
50        label => "dist author in",
51        pretty_id => "JOHNDOE/Bogus-Module-1.23.tar.gz",
52        name => "t-Fail",
53        version => 1.23,
54        grade => "fail",
55        phase => "test",
56        command => "$perl Makefile.PL",
57        will_send => 0,
58    },
59    {
60        label => "dist name in",
61        pretty_id => "JOHNQP/Bogus-SkipModule-1.23.tar.gz",
62        name => "t-Fail",
63        version => 1.23,
64        grade => "fail",
65        phase => "test",
66        command => "$perl Makefile.PL",
67        will_send => 0,
68    },
69    {
70        label => "dist name in - case insensitive",
71        pretty_id => "johnqp/bogus-skipmodule-1.23.tar.gz",
72        name => "t-Fail",
73        version => 1.23,
74        grade => "fail",
75        phase => "test",
76        command => "$perl Makefile.PL",
77        will_send => 0,
78    },
79);
80
81plan tests => 1 + @cases * (test_fake_config_plan() + test_dispatch_plan());
82
83#--------------------------------------------------------------------------#
84# tests
85#--------------------------------------------------------------------------#
86
87require_ok('CPAN::Reporter');
88
89# test send_skipfile
90for my $case ( @cases ) {
91    local $case->{label} = $case->{label} . " send_skipfile";
92    $case->{dist} = t::MockCPANDist->new(
93        pretty_id => $case->{pretty_id},
94        %mock_dist_options,
95    );
96    test_fake_config(
97        send_report => "yes",
98        send_duplicates => "yes",
99        send_skipfile => "$skipfile",
100    );
101    test_dispatch(
102        $case,
103        will_send => $case->{will_send},
104    );
105}
106
107