process.t revision 1.1.1.1
1#!/usr/bin/perl -w
2
3use strict;
4use lib 't/lib';
5
6my $hires;
7
8BEGIN {
9    $hires = eval 'use Time::HiRes qw(sleep); 1';
10}
11
12use Test::More (
13      $^O eq 'VMS' ? ( skip_all => 'VMS' )
14    : $hires ? ( tests => 9 * 3 )
15    : ( skip_all => 'Need Time::HiRes' )
16);
17
18use File::Spec;
19use TAP::Parser::Iterator::Process;
20
21my @expect = (
22    '1..5',
23    'ok 1 00000',
24    'ok 2',
25    'not ok 3',
26    'ok 4',
27    'ok 5 00000',
28);
29
30my $source = File::Spec->catfile(
31    't',
32    'sample-tests',
33    'delayed'
34);
35
36for 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}
54