Skip to content

Commit 4ed92b5

Browse files
committed
Cover data-loss fix to Proc::Async.
1 parent 2d7448c commit 4ed92b5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

S17-procasync/basic.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 32;
5+
plan 33;
66

77
my $pc = $*DISTRO.is-win
88
?? Proc::Async.new( 'cmd', </c echo Hello World> )
@@ -91,3 +91,18 @@ is $stderr, '', 'got correct STDERR';
9191

9292
throws-like { Proc::Async.new }, X::Multi::NoMatch,
9393
'attempting to create Proc::Async with wrong arguments throws';
94+
95+
# Check we don't have races if you tap the stdout supply after starting.
96+
{
97+
my $pc = $*DISTRO.is-win
98+
?? Proc::Async.new( 'cmd', </c echo Hello World> )
99+
!! Proc::Async.new( 'echo', <Hello World> );
100+
my $stdout = $pc.stdout;
101+
my $done = $pc.start;
102+
sleep 0.1; # Enough to make the test flap if we're doing things wrong
103+
my $captured = '';
104+
$stdout.tap({ $captured ~= $_ });
105+
await $done;
106+
is $captured, "Hello World\n",
107+
"Tapping stdout supply after start of process does not lose data";
108+
}

0 commit comments

Comments
 (0)