summaryrefslogtreecommitdiff
path: root/lib/Test/Harness/t/callback.t
blob: eeea1e4ecd00536f72840218b021f7c4f76770da (plain)
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
#!/usr/bin/perl -w

BEGIN {
    if( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = ('../lib', 'lib');
    }
    else {
        unshift @INC, 't/lib';
    }
}

use File::Spec::Functions;

my $SAMPLE_TESTS = $ENV{PERL_CORE}
    ? catdir(curdir(), 'lib', 'sample-tests')
    : catdir(curdir(), 't', 'sample-tests');

use Test::More;

%samples = (
            bailout     => [qw( header test test test bailout )],
            combined    => ['header', ('test') x 10],
            descriptive => ['header', ('test') x 5 ],
            duplicates  => ['header', ('test') x 11 ],
            head_end    => [qw( other test test test test 
                                other header other other )],
            head_fail   => [qw( other test test test test
                                other header other other )],
            no_nums     => ['header', ('test') x 5 ],
            out_of_order=> [('test') x 10, 'header', ('test') x 5],
            simple      => [qw( header test test test test test )],
            simple_fail => [qw( header test test test test test )],
            'skip'      => [qw( header test test test test test )],
            skipall     => [qw( header )],
            skipall_nomsg => [qw( header )],
            skip_nomsg  => [qw( header test )],
            taint       => [qw( header test )],
            'todo'      => [qw( header test test test test test )],
            todo_inline => [qw( header test test test )],
            vms_nit     => [qw( header other test test )],
            with_comments => [qw( other header other test other test test
                                  test other other test other )],
           );

plan tests => scalar keys %samples;

use Test::Harness::Straps;
my $strap = Test::Harness::Straps->new;
$strap->{callback} = sub {
    my($self, $line, $type, $totals) = @_;
    push @out, $type;
};
                            
$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS';

while( my($test, $expect) = each %samples ) {
    local @out = ();

    $strap->analyze_file($^O eq 'macos' ?
			 catfile($SAMPLE_TESTS, $test) :
			 "$SAMPLE_TESTS/$test");

    is_deeply(\@out, $expect,   "$test callback");
}