File: 02-callback.t

package info (click to toggle)
libparallel-forkmanager-perl 2.04-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: perl: 479; xml: 297; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 718 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use warnings;

use Test::More tests => 2;

diag 'This test can take 10-20 seconds, please wait. Started at ' . localtime;

my @out = qx{$^X -Ilib examples/callback.pl};
$_ =~ s/pid:\s*-?\d+/pid:/g for @out;
$_ =~ s/PID\s*-?\d+/PID/g for @out;
my @wait  = grep { /Have to wait for one children/ } @out;
@out = grep { !/Have to wait for one children/ } @out;
@out = sort @out;
cmp_ok scalar(@wait), '>', 10, 'Have to wait for one children at least 10 times';


my @expected = do { open my $fh, '<', 't/callback.txt'; <$fh> };
$_ =~ s/pid:\s*-?\d+/pid:/g for @expected;
$_ =~ s/PID\s*-?\d+/PID/g for @expected;
@expected = sort @expected;
is_deeply \@out, \@expected, 'callback worked' or diag explain @out;