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