From 7ab614c9ff63436e7f67753f62c1cdd66ec7e909 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sat, 13 Apr 2024 19:22:28 +0200 Subject: [PATCH] Fix tests on Windows --- test/ResourceOutputStreamTest.php | 8 +++++++- test/ResourceStreamTest.php | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/ResourceOutputStreamTest.php b/test/ResourceOutputStreamTest.php index a1441d7..2394dae 100644 --- a/test/ResourceOutputStreamTest.php +++ b/test/ResourceOutputStreamTest.php @@ -5,6 +5,7 @@ use Amp\ByteStream\ResourceOutputStream; use Amp\ByteStream\StreamException; use Amp\PHPUnit\AsyncTestCase; +use const PHP_OS; class ResourceOutputStreamTest extends AsyncTestCase { @@ -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 diff --git a/test/ResourceStreamTest.php b/test/ResourceStreamTest.php index dc1c412..fcf8277 100644 --- a/test/ResourceStreamTest.php +++ b/test/ResourceStreamTest.php @@ -10,6 +10,7 @@ use Amp\Delayed; use Amp\PHPUnit\AsyncTestCase; use Amp\Success; +use const PHP_OS; class ResourceStreamTest extends AsyncTestCase { @@ -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()