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
|
#!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;
require Test::Harness;
my $harness_version = Test::Harness->VERSION;
my $is_th2xx = $harness_version < 3;
my $is_th3xx = $harness_version >= 3;
my $is_th305 = $harness_version >= '3.05';
# every distro must have th2xx as a fallback
my @test_distros = (
{
name => 't-NoOutput',
th2xx => {
eumm_success => 1,
eumm_grade => "unknown",
eumm_msg => "No tests were run",
mb_success => 1,
mb_grade => "unknown",
mb_msg => "No tests were run",
},
th305 => {
eumm_success => 0,
eumm_grade => "fail",
eumm_msg => "One or more tests failed",
mb_success => 0,
mb_grade => "fail",
mb_msg => "One or more tests failed",
},
},
{
name => 't-NoOutput-die',
th2xx => {
eumm_success => 1,
eumm_grade => "unknown",
eumm_msg => "No tests were run",
mb_success => 1,
mb_grade => "unknown",
mb_msg => "No tests were run",
},
th305 => {
eumm_success => 0,
eumm_grade => "fail",
eumm_msg => "One or more tests failed",
mb_success => 0,
mb_grade => "fail",
mb_msg => "One or more tests failed",
},
},
{
name => 'test.pl-NoOutput-OK',
th2xx => {
eumm_success => 1,
eumm_grade => "pass",
eumm_msg => "'make test' no errors",
mb_success => 1,
mb_grade => "unknown",
mb_msg => "No tests were run",
},
th305 => {
eumm_success => 1,
eumm_grade => "pass",
eumm_msg => "'make test' no errors",
mb_success => 0,
mb_grade => "fail",
mb_msg => "One or more tests failed",
},
},
{
name => 'test.pl-NoOutput-NOK',
th2xx => {
eumm_success => 0,
eumm_grade => "fail",
eumm_msg => "'make test' error detected",
mb_success => 1,
mb_grade => "unknown",
mb_msg => "No tests were run",
},
th305 => {
eumm_success => 0,
eumm_grade => "fail",
eumm_msg => "'make test' error detected",
mb_success => 0,
mb_grade => "fail",
mb_msg => "One or more tests failed",
},
},
);
plan tests => 1 + test_fake_config_plan()
+ test_grade_test_plan() * @test_distros;
#--------------------------------------------------------------------------#
# Fixtures
#--------------------------------------------------------------------------#
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",
);
#--------------------------------------------------------------------------#
# tests
#--------------------------------------------------------------------------#
require_ok('CPAN::Reporter');
test_fake_config();
for my $case ( @test_distros ) {
my $target_version = $is_th305 && exists $case->{th305} ? "th305"
: $is_th3xx && exists $case->{th3xx} ? "th3xx"
: "th2xx"
;
my %target_case = (
name => $case->{name},
%{$case->{$target_version}},
);
test_grade_test( \%target_case, $mock_dist );
}
|