summaryrefslogtreecommitdiff
path: root/cpan/Test-Harness/t/process.t
blob: 5135d67f95faa0641498b5f0efdd055cb884a7c1 (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
#!/usr/bin/perl -w

use strict;
use lib 't/lib';

my $hires;

BEGIN {
    $hires = eval 'use Time::HiRes qw(sleep); 1';
}

use Test::More (
      $^O eq 'VMS' ? ( skip_all => 'VMS' )
    : $hires ? ( tests => 9 * 3 )
    : ( skip_all => 'Need Time::HiRes' )
);

use File::Spec;
use TAP::Parser::Iterator::Process;

my @expect = (
    '1..5',
    'ok 1 00000',
    'ok 2',
    'not ok 3',
    'ok 4',
    'ok 5 00000',
);

my $source = File::Spec->catfile(
    't',
    'sample-tests',
    'delayed'
);

for my $chunk_size ( 1, 4, 65536 ) {
    for my $where ( 0 .. 8 ) {

        my $proc = TAP::Parser::Iterator::Process->new(
            {   _chunk_size => $chunk_size,
                command     => [ $^X, $source, ( 1 << $where ) ]
            }
        );

        my @got = ();
        while ( defined( my $line = $proc->next_raw ) ) {
            push @got, $line;
        }

        is_deeply \@got, \@expect,
          "I/O ok with delay at position $where, chunk size $chunk_size";
    }
}