File: RunTests.pm

package info (click to toggle)
libdist-zilla-plugin-makemaker-fallback-perl 0.033-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: perl: 349; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Capture::Tiny 'capture';
use Try::Tiny;

sub runtests
{
    my $tzil = shift;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my $die;
    my ($stdout, $stderr, @result) = capture {
        try {
            $tzil->test;
        }
        catch {
            chomp($die = $_);
            undef;
        };
    };

    if (defined $die)
    {
        fail $die;
        diag $stdout if $stdout;
        diag $stderr if $stderr;
        diag explain $tzil->log_messages;
        return;
    }

    # success
    note $stdout if $stdout;
    note $stderr if $stderr;
    return 1;
}

1;