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
  
     | 
    
      #!perl
use strict;
use warnings;
use lib 't/lib';
use Capture::Tiny qw/capture/;
use Dist::Zilla::App::Tester;
use Test::DZil;
use Test::Requires { 'Dist::Zilla::Tester' => 4.300017 };
use Test::More 0.88;
use Try::Tiny;
## XT FILE GUTS
my $xt_fail = << 'HERE';
use Test::More tests => 1;
fail("doomed to fail");
HERE
my $xt_pass = << 'HERE';
use Test::More tests => 1;
pass("destined to succeed");
HERE
## Tests start here
{
    my $tzil;
    try {
        $tzil = Dist::Zilla::Tester->from_config(
            { dist_root => 'corpus/DZ' },
            { add_files => { 'source/xt/checkme.t' => $xt_fail, }, },
        );
        ok( $tzil, "created test dist that will fail xt tests" );
        capture { $tzil->release };
    }
    catch {
        my $err = $_;
        like( $err, qr/Fatal errors in xt/i, "CheckExtraTests caught xt test failure", );
        ok(
            !grep( {/fake release happen/i} @{ $tzil->log_messages } ),
            "FakeRelease did not happen",
        );
    }
}
{
    my $tzil = Dist::Zilla::Tester->from_config(
        { dist_root => 'corpus/DZ' },
        { add_files => { 'source/xt/checkme.t' => $xt_pass, }, },
    );
    ok( $tzil, "created test dist that will pass xt tests" );
    capture { $tzil->release };
    ok(
        !grep( {/Fatal errors in xt/i} @{ $tzil->log_messages } ),
        "No xt errors logged",
    );
    ok(
        grep( {/fake release happen/i} @{ $tzil->log_messages } ),
        "FakeRelease executed",
    );
}
done_testing;
 
     |