File: pre_post_nested.t

package info (click to toggle)
libtest-aggregate-perl 0.364-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 200 kB
  • sloc: perl: 899; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,328 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
#!/usr/bin/perl

use strict;
use warnings;

use lib 'lib', 't/lib';
use Test::More;

plan +Test::More->can('subtest')
  ? ( tests => 6 )
  : ( skip_all => 'Need Test::More::subtest() for this test' );
use Test::Aggregate::Nested;

my ( $startup, $shutdown ) = ( 0, 0 );
my ( $setup,   $teardown ) = ( 0, 0 );

$SIG{__WARN__} = sub {
    my $warning = shift;
    if ( $warning =~ m{Can't locate Data/Dump/Streamer\.pm in \@INC} ) {    #'
        return;
    }
    CORE::warn($warning);
};

my $found_it;
subtest 'nested tests' => sub {
    my $tests = Test::Aggregate::Nested->new(
        {
            dirs     => 'aggtests',
            findbin  => 1,
            startup  => sub { $startup++ },
            shutdown => sub { $shutdown++ },
            setup    => sub {
                my $file = shift;
                if ( $file =~ /slow_load\.t$/ ) {
                    $found_it = 1;
                }
                $setup++;
            },
            teardown => sub { $teardown++ },
            shuffle  => 1,
        }
    );
    $tests->run;
};
is $startup,  1, 'Startup should be called once';
is $shutdown, 1, '... as should shutdown';
is $setup,    8, 'Setup should be called once for each test program';
is $teardown, 8, '... as should teardown';
ok $found_it, '... and file names should be passed to setup';