2fc943acf35b50c0f74400c99ab140d6cc34cf9a
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness / t / callback.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = ('../lib', 'lib');
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12
13 my $SAMPLE_TESTS = $ENV{PERL_CORE} ? 'lib/sample-tests' : 't/sample-tests';
14
15 use Test::More;
16
17 %samples = (
18             bailout     => [qw( header test test test bailout )],
19             combined    => ['header', ('test') x 10],
20             descriptive => ['header', ('test') x 5 ],
21             duplicates  => ['header', ('test') x 11 ],
22             head_end    => [qw( other test test test test 
23                                 other header other other )],
24             head_fail   => [qw( other test test test test
25                                 other header other other )],
26             no_nums     => ['header', ('test') x 5 ],
27             out_of_order=> [('test') x 10, 'header', ('test') x 5],
28             simple      => [qw( header test test test test test )],
29             simple_fail => [qw( header test test test test test )],
30             'skip'      => [qw( header test test test test test )],
31             skip_all    => [qw( header )],
32             skip_no_msg => [qw( header test )],
33             taint       => [qw( header test )],
34             'todo'      => [qw( header test test test test test )],
35             todo_inline => [qw( header test test test )],
36             vms_nit     => [qw( header other test test )],
37             with_comments => [qw( other header other test other test test
38                                   test other other test other )],
39            );
40
41 plan tests => scalar keys %samples;
42
43 use Test::Harness::Straps;
44 my $strap = Test::Harness::Straps->new;
45 $strap->{callback} = sub {
46     my($self, $line, $type, $totals) = @_;
47     push @out, $type;
48 };
49                             
50 while( my($test, $expect) = each %samples ) {
51     local @out = ();
52     $strap->analyze_file("$SAMPLE_TESTS/$test");
53
54     is_deeply(\@out, $expect,   "$test callback");
55 }