Skip to content
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
12 changes: 4 additions & 8 deletions .github/workflows/benchmark_phpunit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Benchmark PHPUnit

# A/B wall-time benchmark: serial phpunit vs the Go parallel runner.
# A/B wall-time benchmark: serial phpunit vs the fast-unit parallel runner.
# Scheduled only (not on pull requests); runs every 2 hours on ubuntu.
# Reminder: cron fires only from the default branch, so this starts running
# once the file is on `main`.
Expand Down Expand Up @@ -36,10 +36,6 @@ jobs:

- uses: "ramsey/composer-install@v4"

- uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Serial phpunit
shell: bash
run: |
Expand All @@ -48,9 +44,9 @@ jobs:
vendor/bin/phpunit
echo "| ${{ matrix.os }} | ${{ matrix.php-versions }} | serial | $((SECONDS - start))s |" >> "$GITHUB_STEP_SUMMARY"

- name: Go parallel runner
- name: fast-unit runner
shell: bash
run: |
start=$SECONDS
go run ./utils-tests-runner/main.go
echo "| ${{ matrix.os }} | ${{ matrix.php-versions }} | go-runner | $((SECONDS - start))s |" >> "$GITHUB_STEP_SUMMARY"
vendor/bin/fastunit
echo "| ${{ matrix.os }} | ${{ matrix.php-versions }} | fast-unit | $((SECONDS - start))s |" >> "$GITHUB_STEP_SUMMARY"
34 changes: 33 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,36 @@ jobs:

- uses: "ramsey/composer-install@v4"

- run: vendor/bin/phpunit --colors
- run: vendor/bin/fastunit tests rules-tests utils/phpstan/tests

# optional fast feedback on pull requests: run only the tests whose static
# dependency closure changed. NOT a merge gate -- the full "tests" job above
# stays authoritative, since -tia over-approximates but cannot see dynamic
# (reflection / class-string) dependencies.
tests_tia:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 4

name: PHP 8.4 tests (impacted only)
steps:
- uses: actions/checkout@v5

# restore the newest cached hash snapshot; save a fresh one per commit
- uses: actions/cache@v4
with:
path: .fastunit-cache
key: fastunit-tia-${{ github.sha }}
restore-keys: |
fastunit-tia-

-
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
ini-values: zend.assertions=1

- uses: "ramsey/composer-install@v4"

- run: vendor/bin/fastunit -tia tests rules-tests utils/phpstan/tests
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"symplify/phpstan-rules": "^14.12",
"symplify/vendor-patches": "^11.5",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/fast-unit": "^0.1",
"tomasvotruba/type-coverage": "^2.3",
"tomasvotruba/unused-public": "^2.2",
"tracy/tracy": "^2.12"
Expand Down Expand Up @@ -103,8 +104,10 @@
"complete-check": [
"@check-cs",
"@phpstan",
"phpunit"
"@test"
],
"test": "vendor/bin/fastunit tests rules-tests utils/phpstan/tests",
"test-tia": "vendor/bin/fastunit -tia tests rules-tests utils/phpstan/tests",
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"phpstan": "vendor/bin/phpstan analyse --ansi --memory-limit=512M",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Rector\Tests\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector\Fixture;

abstract class FinalPrivate
abstract class FinalPrivateConstructor
{
final private function __construct()
{
Expand Down
10 changes: 10 additions & 0 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ final class RectorConfig extends Container

private static ?bool $recreated = null;

/**
* @internal Resets the root-config detection, so tests that assert on root
* rule registration behave the same whether run alone or batched into one
* warm process by a parallel runner.
*/
public static function resetRecreated(): void
{
self::$recreated = null;
}

public static function configure(): RectorConfigBuilder
{
if (self::$recreated === null) {
Expand Down
6 changes: 4 additions & 2 deletions src/Testing/Fixture/FixtureFileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class FixtureFileFinder
{
/**
* @api used in tests
* @return Iterator<array<int, string>>
* @return Iterator<string, array<int, string>>
*/
public static function yieldDirectory(string $directory, string $suffix = '*.php.inc'): Iterator
{
Expand All @@ -22,7 +22,9 @@ public static function yieldDirectory(string $directory, string $suffix = '*.php
->sortByName();

foreach ($finder as $fileInfo) {
yield [$fileInfo->getRealPath()];
// key the data set by fixture path, so a failure prints the exact
// clickable ".php.inc" file instead of an anonymous "data set #N"
yield $fileInfo->getRealPath() => [$fileInfo->getRealPath()];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time to give this a go 👍

}
}
}
14 changes: 14 additions & 0 deletions tests/Config/RectorConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Tests\Config;

use Rector\Config\RectorConfig;
use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
Expand All @@ -17,6 +18,19 @@

final class RectorConfigTest extends AbstractLazyTestCase
{
protected function setUp(): void
{
parent::setUp();

// these tests assert on root rule registration, which is decided by a
// static "first configure() in the process is root" flag; reset it and
// the registered-rule lists so the assertions hold whether this class
// runs alone or batched into one warm process by a parallel runner
RectorConfig::resetRecreated();
SimpleParameterProvider::setParameter(Option::REGISTERED_RECTOR_RULES, []);
SimpleParameterProvider::setParameter(Option::ROOT_STANDALONE_REGISTERED_RULES, []);
}

public function test(): void
{
$rectorConfig = $this->getContainer();
Expand Down
2 changes: 0 additions & 2 deletions utils-tests-runner/.gitignore

This file was deleted.

93 changes: 0 additions & 93 deletions utils-tests-runner/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions utils-tests-runner/go.mod

This file was deleted.

Loading
Loading