Upgrade to Test::Harness 3.13
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness / t / process.t
CommitLineData
b965d173 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
f7c69158 12use Test::More (
13 $^O eq 'VMS' ? ( skip_all => 'VMS' )
14 : $hires ? ( tests => 9 * 3 )
15 : ( skip_all => 'Need Time::HiRes' )
16);
b965d173 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
f7c69158 30my $source = File::Spec->catfile(
31 ( $ENV{PERL_CORE} ? 'lib' : 't' ),
32 'sample-tests', 'delayed'
33);
b965d173 34
35for my $chunk_size ( 1, 4, 65536 ) {
36 for my $where ( 0 .. 8 ) {
37
38 my $proc = TAP::Parser::Iterator::Process->new(
39 { _chunk_size => $chunk_size,
40 command => [ $^X, $source, ( 1 << $where ) ]
41 }
42 );
43
44 my @got = ();
45 while ( defined( my $line = $proc->next_raw ) ) {
46 push @got, $line;
47 }
48
49 is_deeply \@got, \@expect,
50 "I/O ok with delay at position $where, chunk size $chunk_size";
51 }
52}