File: 63_config_send_report.t

package info (click to toggle)
libcpan-reporter-perl 1.2020-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,752 kB
  • sloc: perl: 5,440; makefile: 2
file content (138 lines) | stat: -rw-r--r-- 3,319 bytes parent folder | download
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
138
#!perl
use strict;
BEGIN{ if (not $] < 5.006) { require warnings; warnings->import } }

select(STDERR); $|=1;
select(STDOUT); $|=1;

use Test::More;
use lib 't/lib';
use MockCPANDist;
use Helper;
use Frontend;
use Config;
use Probe::Perl;

#--------------------------------------------------------------------------#
# Fixtures
#--------------------------------------------------------------------------#

my $make = $Config{make};
my $perl = Probe::Perl->find_perl_interpreter();
$perl = qq{"$perl"};

my $mock_dist = MockCPANDist->new( 
    pretty_id => "JOHNQP/Bogus-Module-1.23.tar.gz",
    prereq_pm       => {
        requires => { 'File::Spec' => 0 },
    },
    author_id       => "JOHNQP",
    author_fullname => "John Q. Public",
);
    
my @cases = (
    {
        label => "send_PL_report 'no'",
        name => "PL-Fail",
        version => 1.23,
        grade => "fail",
        phase => "PL",
        command => "$perl Makefile.PL",
        will_send => 0,
        options => {
            send_report => "yes",
            send_PL_report => "no", 
        },
    },
    {
        label => "send_make_report 'no'",
        label => "first make failure",
        name => "make-Fail",
        version => 1.23,
        grade => "fail",
        phase => "make",
        command => "$make",
        will_send => 0,
        options => { 
            send_report => "yes",
            send_make_report => "no", 
        },
    },
    {
        label => "send_test_report 'no'",
        name => "t-Fail",
        grade => "fail",
        phase => "test",
        command => "$make test",
        will_send => 0,
        options => { 
            send_report => "yes",
            send_test_report => "no", 
        },
    },
    {
        label => "send_PL_report 'yes'",
        name => "PL-Fail",
        version => 1.23,
        grade => "fail",
        phase => "PL",
        command => "$perl Makefile.PL",
        will_send => 1,
        options => {
            send_report => "no",
            send_PL_report => "yes", 
        },
    },
    {
        label => "send_make_report 'yes'",
        label => "first make failure",
        name => "make-Fail",
        version => 1.23,
        grade => "fail",
        phase => "make",
        command => "$make",
        will_send => 1,
        options => { 
            send_report => "no",
            send_make_report => "yes", 
        },
    },
    {
        label => "send_test_report 'yes'",
        name => "t-Fail",
        grade => "fail",
        phase => "test",
        command => "$make test",
        will_send => 1,
        options => { 
            send_report => "no",
            send_test_report => "yes", 
        },
    },
);

my $expected_history_lines = 1; # opening comment line

for my $c ( @cases ) {
    $expected_history_lines++ if not $c->{is_dup}
}

plan tests => 1 + @cases * ( test_fake_config_plan() + test_dispatch_plan() );

#--------------------------------------------------------------------------#
# tests
#--------------------------------------------------------------------------#

require_ok('CPAN::Reporter');

my @results;

for my $case ( @cases ) {
    $case->{dist} = $mock_dist;
    test_fake_config( %{$case->{options}} );
    test_dispatch( 
        $case, 
        will_send => $case->{will_send},
    );
}