Integrate macperl patch #16868.
[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 use File::Spec::Functions;
14
15 my $SAMPLE_TESTS = $ENV{PERL_CORE}
16     ? catdir(curdir(), 'lib', 'sample-tests')
17     : catdir(curdir(), 't', 'sample-tests');
18
19 use Test::More;
20
21 %samples = (
22             bailout     => [qw( header test test test bailout )],
23             combined    => ['header', ('test') x 10],
24             descriptive => ['header', ('test') x 5 ],
25             duplicates  => ['header', ('test') x 11 ],
26             head_end    => [qw( other test test test test 
27                                 other header other other )],
28             head_fail   => [qw( other test test test test
29                                 other header other other )],
30             no_nums     => ['header', ('test') x 5 ],
31             out_of_order=> [('test') x 10, 'header', ('test') x 5],
32             simple      => [qw( header test test test test test )],
33             simple_fail => [qw( header test test test test test )],
34             'skip'      => [qw( header test test test test test )],
35             skip_all    => [qw( header )],
36             skip_no_msg => [qw( header test )],
37             taint       => [qw( header test )],
38             'todo'      => [qw( header test test test test test )],
39             todo_inline => [qw( header test test test )],
40             vms_nit     => [qw( header other test test )],
41             with_comments => [qw( other header other test other test test
42                                   test other other test other )],
43            );
44
45 plan tests => scalar keys %samples;
46
47 use Test::Harness::Straps;
48 my $strap = Test::Harness::Straps->new;
49 $strap->{callback} = sub {
50     my($self, $line, $type, $totals) = @_;
51     push @out, $type;
52 };
53                             
54 while( my($test, $expect) = each %samples ) {
55     local @out = ();
56     $strap->analyze_file(catfile($SAMPLE_TESTS, $test));
57
58     is_deeply(\@out, $expect,   "$test callback");
59 }