~ubuntu-branches/ubuntu/trusty/libtest-roo-perl/trusty-proposed

1 by gregor herrmann
Import upstream version 1.002
1
use 5.008001;
2
use Test::More 0.96;
3
use Capture::Tiny qw/capture/;
4
5
use lib 't/lib';
6
7
my @cases = (
8
    {
9
        label  => "missing role",
10
        file   => "t/bin/role-not-found.pl",
11
        expect => qr/Can't \S+ RoleNotFoundAnywhere\.pm in \@INC/,
12
    },
13
    {
14
        label  => "requires not satisfied",
15
        file   => "t/bin/unsatisfied.pl",
16
        expect => qr/Can't apply RequiresFixture to main/,
17
    },
18
    {
19
        label  => "Test::Roo loads strictures",
20
        file   => "t/bin/not-strict.pl",
21
        expect => qr/requires explicit package name/,
22
    },
23
    {
24
        label   => "skip_all respected",
25
        file    => "t/bin/skip-all.pl",
26
        expect  => qr/We just want to skip/,
27
        exit_ok => 1,
28
        stdout  => 1,
29
    },
30
    {
31
        label   => "skip_all respected in role",
32
        file    => "t/bin/skip-in-role.pl",
33
        expect  => qr/We just want to skip/,
34
        exit_ok => 1,
35
        stdout  => 1,
36
    },
37
);
38
39
for my $c (@cases) {
40
    my ( $output, $error, $rc ) = capture { system( $^X, $c->{file} ) };
41
    subtest $c->{label} => sub {
42
        if ( $c->{exit_ok} ) {
43
            ok( !$rc, "exit ok" );
44
        }
45
        else {
46
            ok( $rc, "nonzero exit" );
47
        }
48
        like( $c->{stdout} ? $output : $error, $c->{expect}, "exception text" );
49
    };
50
}
51
52
done_testing;
53
#
54
# This file is part of Test-Roo
55
#
56
# This software is Copyright (c) 2013 by David Golden.
57
#
58
# This is free software, licensed under:
59
#
60
#   The Apache License, Version 2.0, January 2004
61
#
62
# vim: ts=4 sts=4 sw=4 et: