1#!/usr/bin/perl -w 2 3BEGIN { 4 if( $ENV{PERL_CORE} ) { 5 chdir 't'; 6 @INC = ('../lib', 'lib'); 7 } 8 else { 9 unshift @INC, 't/lib'; 10 } 11} 12 13use Test::More; 14use File::Spec; 15 16BEGIN { 17 use vars qw( %samples ); 18 19 %samples = ( 20 bailout => [qw( header test test test bailout )], 21 combined => ['header', ('test') x 10], 22 descriptive => ['header', ('test') x 5 ], 23 duplicates => ['header', ('test') x 11 ], 24 head_end => [qw( other test test test test 25 other header other other )], 26 head_fail => [qw( other test test test test 27 other header other other )], 28 no_nums => ['header', ('test') x 5 ], 29 out_of_order=> [('test') x 10, 'header', ('test') x 5], 30 simple => [qw( header test test test test test )], 31 simple_fail => [qw( header test test test test test )], 32 'skip' => [qw( header test test test test test )], 33 skipall => [qw( header )], 34 skipall_nomsg => [qw( header )], 35 skip_nomsg => [qw( header test )], 36 taint => [qw( header test )], 37 'todo' => [qw( header test test test test test )], 38 todo_inline => [qw( header test test test )], 39 vms_nit => [qw( header other test test )], 40 with_comments => [qw( other header other test other test test 41 test other other test other )], 42 ); 43 plan tests => 2 + scalar keys %samples; 44} 45 46BEGIN { use_ok( 'Test::Harness::Straps' ); } 47 48my $Curdir = File::Spec->curdir; 49my $SAMPLE_TESTS = $ENV{PERL_CORE} 50 ? File::Spec->catdir($Curdir, 'lib', 'sample-tests') 51 : File::Spec->catdir($Curdir, 't', 'sample-tests'); 52 53my $strap = Test::Harness::Straps->new; 54isa_ok( $strap, 'Test::Harness::Straps' ); 55$strap->{callback} = sub { 56 my($self, $line, $type, $totals) = @_; 57 push @out, $type; 58}; 59 60for my $test ( sort keys %samples ) { 61 my $expect = $samples{$test}; 62 63 local @out = (); 64 $strap->analyze_file(File::Spec->catfile($SAMPLE_TESTS, $test)); 65 66 is_deeply(\@out, $expect, "$test callback"); 67} 68