File: parallel.t

package info (click to toggle)
libipc-run-perl 0.94-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 748 kB
  • sloc: perl: 5,750; makefile: 5
file content (57 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (3)
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
54
55
56
57
#!/usr/bin/perl

=pod

=head1 NAME

parallel.t - Test suite for running multiple processes in parallel.

=cut

use strict;
BEGIN { 
	$|  = 1;
	$^W = 1;
	if( $ENV{PERL_CORE} ) {
		chdir '../lib/IPC/Run' if -d '../lib/IPC/Run';
		unshift @INC, 'lib', '../..';
		$^X = '../../../t/' . $^X;
	}
}

## Handy to have when our output is intermingled with debugging output sent
## to the debugging fd.
select STDERR;
select STDOUT;

BEGIN {
    use Test::More;
    if($^O eq 'MSWin32') {
	plan skip_all => 'Parallel tests are dangerous on MSWin32';
    } else {
	plan tests => 6;
    }

}
use IPC::Run qw( start pump finish );

my $text1 = "Hello world 1\n";
my $text2 = "Hello world 2\n";

my @perl    = ( $^X );
my @catter = ( @perl, '-pe1' );

my ( $h1, $h2 );
my ( $out1, $out2 );
$h1 = start \@catter, "<", \$text1, ">", \$out1;
ok( $h1 );
$h2 = start \@catter, "<", \$text2, ">", \$out2;
ok( $h2 );
pump $h1;
ok( 1 );
pump $h2;
ok( 1 );
finish $h1;
ok( 1 );
finish $h2;
ok( 1 );