mirror of
https://github.com/danog/file.git
synced 2024-11-26 11:54:54 +01:00
Clean up execute for tests
This commit is contained in:
parent
4cccc8d0f7
commit
2eb8eb7662
@ -2,11 +2,15 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class BlockingDriverTest extends DriverTest {
|
||||
protected function execute(callable $cb) {
|
||||
\Amp\Loop::run(function () use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\BlockingDriver);
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
Loop::run(function () use ($cb) {
|
||||
File\filesystem(new File\BlockingDriver);
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,15 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class BlockingHandleTest extends HandleTest {
|
||||
protected function execute(callable $cb) {
|
||||
\Amp\Loop::run(function () use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\BlockingDriver);
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
Loop::run(function () use ($cb) {
|
||||
File\filesystem(new File\BlockingDriver);
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,21 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class EioDriverTest extends DriverTest {
|
||||
protected function execute(callable $cb) {
|
||||
if (\extension_loaded("eio")) {
|
||||
\Amp\Loop::run(function () use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\EioDriver);
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
} else {
|
||||
if (!\extension_loaded("eio")) {
|
||||
$this->markTestSkipped(
|
||||
"eio extension not loaded"
|
||||
);
|
||||
}
|
||||
|
||||
Loop::run(function () use ($cb) {
|
||||
File\filesystem(new File\EioDriver);
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,21 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class EioHandleTest extends AsyncHandleTest {
|
||||
protected function execute(callable $cb) {
|
||||
if (\extension_loaded("eio")) {
|
||||
\Amp\Loop::run(function () use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\EioDriver);
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
} else {
|
||||
if (!\extension_loaded("eio")) {
|
||||
$this->markTestSkipped(
|
||||
"eio extension not loaded"
|
||||
);
|
||||
}
|
||||
|
||||
Loop::run(function () use ($cb) {
|
||||
File\filesystem(new File\EioDriver);
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,24 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class UvDriverTest extends DriverTest {
|
||||
protected function execute(callable $cb) {
|
||||
if (\extension_loaded("uv")) {
|
||||
$loop = new Loop\UvDriver;
|
||||
Loop::set($loop);
|
||||
Loop::run(function () use ($cb, $loop) {
|
||||
\Amp\File\filesystem(new \Amp\File\UvDriver($loop));
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
} else {
|
||||
if (!\extension_loaded("uv")) {
|
||||
$this->markTestSkipped(
|
||||
"php-uv extension not loaded"
|
||||
);
|
||||
}
|
||||
|
||||
$loop = new Loop\UvDriver;
|
||||
|
||||
Loop::set($loop);
|
||||
Loop::run(function () use ($cb, $loop) {
|
||||
File\filesystem(new File\UvDriver($loop));
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,24 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\File;
|
||||
use Amp\Loop;
|
||||
use function Amp\asyncCall;
|
||||
|
||||
class UvHandleTest extends AsyncHandleTest {
|
||||
protected function execute(callable $cb) {
|
||||
if (\extension_loaded("uv")) {
|
||||
$loop = new Loop\UvDriver;
|
||||
Loop::set($loop);
|
||||
Loop::run(function () use ($cb, $loop) {
|
||||
\Amp\File\filesystem(new \Amp\File\UvDriver($loop));
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
} else {
|
||||
if (!\extension_loaded("uv")) {
|
||||
$this->markTestSkipped(
|
||||
"php-uv extension not loaded"
|
||||
);
|
||||
}
|
||||
|
||||
$loop = new Loop\UvDriver;
|
||||
|
||||
Loop::set($loop);
|
||||
Loop::run(function () use ($cb, $loop) {
|
||||
File\filesystem(new File\UvDriver($loop));
|
||||
asyncCall($cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user