Move Test::Harness from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Test-Harness / t / process.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib 't/lib';
5
6 my $hires;
7
8 BEGIN {
9     $hires = eval 'use Time::HiRes qw(sleep); 1';
10 }
11
12 use Test::More (
13       $^O eq 'VMS' ? ( skip_all => 'VMS' )
14     : $hires ? ( tests => 9 * 3 )
15     : ( skip_all => 'Need Time::HiRes' )
16 );
17
18 use File::Spec;
19 use TAP::Parser::Iterator::Process;
20
21 my @expect = (
22     '1..5',
23     'ok 1 00000',
24     'ok 2',
25     'not ok 3',
26     'ok 4',
27     'ok 5 00000',
28 );
29
30 my $source = File::Spec->catfile(
31     't',
32     'sample-tests',
33     'delayed'
34 );
35
36 for my $chunk_size ( 1, 4, 65536 ) {
37     for my $where ( 0 .. 8 ) {
38
39         my $proc = TAP::Parser::Iterator::Process->new(
40             {   _chunk_size => $chunk_size,
41                 command     => [ $^X, $source, ( 1 << $where ) ]
42             }
43         );
44
45         my @got = ();
46         while ( defined( my $line = $proc->next_raw ) ) {
47             push @got, $line;
48         }
49
50         is_deeply \@got, \@expect,
51           "I/O ok with delay at position $where, chunk size $chunk_size";
52     }
53 }