Skip to content

Commit

Permalink
Fix tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Apr 13, 2024
1 parent a453d66 commit 7ab614c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/ResourceOutputStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Amp\ByteStream\ResourceOutputStream;
use Amp\ByteStream\StreamException;
use Amp\PHPUnit\AsyncTestCase;
use const PHP_OS;

class ResourceOutputStreamTest extends AsyncTestCase
{
Expand Down Expand Up @@ -47,9 +48,14 @@ public function testBrokenPipe(): ?\Generator
\fclose($b);

$this->expectException(StreamException::class);
$this->expectExceptionMessage(/* S|s */ "end of 6 bytes failed with errno=32 Broken pipe");
$this->expectExceptionMessage(/* S|s */ "end of 6 bytes failed with errno=" . (\stripos(PHP_OS, "win") === 0 ? "10053" : "32 Broken pipe"));

yield $stream->write("foobar");

// The first write still succeeds somehow on Windows...
if (\stripos(PHP_OS, "win") === 0) {
yield $stream->write("foobar");
}
}

public function testClosedRemoteSocket(): ?\Generator
Expand Down
6 changes: 6 additions & 0 deletions test/ResourceStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Amp\Delayed;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Success;
use const PHP_OS;

class ResourceStreamTest extends AsyncTestCase
{
Expand Down Expand Up @@ -77,6 +78,11 @@ public function testThrowsOnExternallyShutdownStreamWithLargePayload()
$b->close();

yield $writePromise;

// Windows apparently always needs another write...
if (\stripos(PHP_OS, "win") === 0) {
yield $a->write("foobar");
}
}

public function testThrowsOnExternallyShutdownStreamWithSmallPayloads()
Expand Down

0 comments on commit 7ab614c

Please sign in to comment.