Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more yield, using revolt, amp and fiber #55

Merged
merged 10 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1']
php-version: ['8.1', '8.2']
composer-flags: ['']
name: ['']
include:
- php-version: '7.3'
- php-version: '8.1'
composer-flags: '--prefer-lowest'
name: '(prefer lowest dependencies)'
name: Tests PHP ${{ matrix.php-version }} ${{ matrix.name }}
Expand Down
23 changes: 0 additions & 23 deletions bin/smoker

This file was deleted.

36 changes: 21 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
}
],
"bin": [
"bin/asynit",
"bin/smoker"
"bin/asynit"
],
"autoload": {
"psr-4": {
Expand All @@ -27,24 +26,31 @@
"test": "bin/asynit tests/"
},
"require": {
"php": "^7.3 || ^8.0",
"amphp/http-client": "^3.0.14",
"amphp/sync": "^1.0",
"bovigo/assert": "^6.2",
"doctrine/annotations": "^1.2",
"doctrine/collections": "^1.3",
"guzzlehttp/psr7": "^1.4",
"php-http/client-common": "^2.0",
"php-http/message": "^1.3",
"php": "^8.1",
"amphp/amp": "^3.0",
"amphp/sync": "^2.0",
"bovigo/assert": "^7.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/dom-crawler": "^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0"
"symfony/finder": "^4.4 || ^5.0 || ^6.0"
},
"suggest": {
"amphp/http-client": "To use the web test case trait",
"nyholm/psr7": "To use the web test case trait"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.10"
"amphp/http-client": "v5.0.0-beta.11",
"friendsofphp/php-cs-fixer": "^v2.19.3",
"nyholm/psr7": "^1.8.0",
"php-http/client-common": "^2.4",
"php-http/message": "^1.3",
"phpstan/phpstan": "^1.10"
},
"conflict": {
"amphp/http-client": "<v5.0.0",
"symfony/options-resolver": "<4.4.30 || <5.3 >= 5.0"
},
"prefer-stable": true,
"minimum-stability": "dev",
"config": {
"sort-packages": true
}
Expand Down
2 changes: 1 addition & 1 deletion example/HttpClientOverrideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class HttpClientOverrideTest extends \Asynit\TestCase
{
public function setUp(\Http\Client\HttpAsyncClient $asyncClient): \Http\Client\HttpAsyncClient
public function setUp(Http\Client\HttpAsyncClient $asyncClient): Http\Client\HttpAsyncClient
{
$uri = (new \Http\Message\UriFactory\GuzzleUriFactory())->createUri('http://httpbin.org');

Expand Down
27 changes: 0 additions & 27 deletions src/Annotation/Depend.php

This file was deleted.

28 changes: 0 additions & 28 deletions src/Annotation/DisplayName.php

This file was deleted.

10 changes: 9 additions & 1 deletion src/Assert/AssertCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Asynit\Assert;

use Asynit\Attribute\OnCreate;
use Asynit\Test;
use function bovigo\assert\counting;
use function bovigo\assert\exporter;
use function bovigo\assert\predicate\contains;
Expand Down Expand Up @@ -47,7 +49,13 @@

trait AssertCaseTrait
{
private $test;
protected Test $test;

#[OnCreate]
public function setUpTest(Test $test): void
{
$this->test = $test;
}

/**
* Asserts that an array has a specified key.
Expand Down
20 changes: 3 additions & 17 deletions src/Assert/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@

class Assertion extends BaseAssertion
{
/**
* value to do the assertion on.
*
* @var mixed
*/
private $value;
private mixed $value;

/**
* @var \SebastianBergmann\Exporter\Exporter
*/
private $exporter;
private Exporter $exporter;

/**
* @var Test
*/
private $test;
private Test $test;

/**
* constructor.
Expand All @@ -43,9 +32,6 @@ public function __construct($value, Exporter $exporter, Test $test)
$this->test = $test;
}

/** @var Test */
public static $currentTest;

public function evaluate(Predicate $predicate, string $description = null): bool
{
try {
Expand Down
11 changes: 11 additions & 0 deletions src/Attribute/Depend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Asynit\Attribute;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Depend
{
public function __construct(public string $dependency)
{
}
}
13 changes: 13 additions & 0 deletions src/Attribute/DisplayName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Asynit\Annotation;

#[\Attribute(\Attribute::TARGET_METHOD)]
class DisplayName
{
public function __construct(public string $name)
{
}
}
10 changes: 10 additions & 0 deletions src/Attribute/OnCreate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Asynit\Annotation;

#[\Attribute(\Attribute::TARGET_METHOD)]
class OnCreate
{
}
10 changes: 10 additions & 0 deletions src/Attribute/Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Asynit\Attribute;

#[\Attribute(\Attribute::TARGET_METHOD)]
class Test
{
}
10 changes: 10 additions & 0 deletions src/Attribute/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Asynit\Annotation;

#[\Attribute(\Attribute::TARGET_CLASS)]
class TestCase
{
}
13 changes: 3 additions & 10 deletions src/Command/AsynitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

namespace Asynit\Command;

use Amp\Loop;
use Asynit\Output\OutputFactory;
use Asynit\Parser\TestPoolBuilder;
use Asynit\Parser\TestsFinder;
use Asynit\Runner\PoolRunner;
use Asynit\TestWorkflow;
use Doctrine\Common\Annotations\AnnotationReader;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -55,16 +52,12 @@ protected function execute(InputInterface $input, OutputInterface $output)

list($chainOutput, $countOutput) = (new OutputFactory($input->getOption('order')))->buildOutput(\count($testMethods));

// Build services for parsing and running tests
$builder = new TestPoolBuilder(new AnnotationReader());
$runner = new PoolRunner(new GuzzleMessageFactory(), new TestWorkflow($chainOutput), $input->getOption('concurrency'));
$builder = new TestPoolBuilder();
$runner = new PoolRunner(new TestWorkflow($chainOutput), $input->getOption('concurrency'));

// Build a list of tests from the directory
$pool = $builder->build($testMethods);

Loop::run(function () use ($runner, $pool) {
$runner->loop($pool);
});
$runner->loop($pool);

// Return the number of failed tests
return $countOutput->getFailed();
Expand Down
61 changes: 0 additions & 61 deletions src/Command/SmokerCommand.php

This file was deleted.

Loading