diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bb4bec6..5c80602f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,4 +43,4 @@ jobs: - name: Unit Tests in Parallel run: composer test:parallel - if: startsWith(matrix.os, 'windows') != true + diff --git a/composer.json b/composer.json index 746c2c29..2d3be6e1 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ ], "require": { "php": "^8.1.0", - "brianium/paratest": "^7.1.2", + "brianium/paratest": "^7.1.3", "nunomaduro/collision": "^7.4.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin-arch": "^2.1.1", - "phpunit/phpunit": "^10.0.19" + "phpunit/phpunit": "^10.1.0" }, "conflict": { "webmozart/assert": "<1.11.0", - "phpunit/phpunit": ">10.0.19" + "phpunit/phpunit": "<10.1.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index c626b394..4aac1aa2 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -21,9 +21,9 @@ ./tests/Fixtures/Inheritance - + ./src - + diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index eadfada8..f8c4d1a4 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -34,6 +34,7 @@ use PHPUnit\Event\TestSuite\Finished as TestSuiteFinished; use PHPUnit\Event\TestSuite\Started as TestSuiteStarted; use PHPUnit\Event\UnknownSubscriberTypeException; use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade; +use ReflectionClass; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; @@ -207,13 +208,17 @@ final class TeamCityLogger $style = new Style($this->output); $telemetry = $event->telemetryInfo(); + if ($this->withoutDuration) { + $reflector = new ReflectionClass($telemetry); + + $property = $reflector->getProperty('current'); + $property->setAccessible(true); + $snapshot = $property->getValue($telemetry); + assert($snapshot instanceof Snapshot); + $telemetry = new Info( - new Snapshot( - $telemetry->time(), - $telemetry->memoryUsage(), - $telemetry->peakMemoryUsage(), - ), + $snapshot, Duration::fromSecondsAndNanoseconds(1, 0), $telemetry->memoryUsageSinceStart(), $telemetry->durationSincePrevious(), diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index 95aec81d..aff82fa4 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -7,6 +7,7 @@ namespace Pest\Plugins\Parallel\Support; use NunoMaduro\Collision\Adapters\Phpunit\State; use NunoMaduro\Collision\Adapters\Phpunit\Style; use ParaTest\Options; +use PHPUnit\Event\Telemetry\GarbageCollectorStatus; use PHPUnit\Event\Telemetry\HRTime; use PHPUnit\Event\Telemetry\Info; use PHPUnit\Event\Telemetry\MemoryUsage; @@ -122,11 +123,25 @@ final class CompactPrinter $snapshotDuration = HRTime::fromSecondsAndNanoseconds((int) $duration->asSeconds(), $nanoseconds); $telemetryDuration = \PHPUnit\Event\Telemetry\Duration::fromSecondsAndNanoseconds((int) $duration->asSeconds(), $nanoseconds); + $status = gc_status(); + + $garbageCollectorStatus = new GarbageCollectorStatus( + $status['runs'], + $status['collected'], + $status['threshold'], + $status['roots'], + null, + null, + null, + null, + ); + $telemetry = new Info( new Snapshot( $snapshotDuration, MemoryUsage::fromBytes(0), MemoryUsage::fromBytes(0), + $garbageCollectorStatus, ), $telemetryDuration, MemoryUsage::fromBytes(0), diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 9a284b40..3f31bc6d 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -43,15 +43,19 @@ --enforce-time-limit ................. Enforce time limit based on test size --default-time-limit [sec] Timeout in seconds for tests that have no declared size --dont-report-useless-tests .. Do not report tests that do not test anything - --stop-on-defect ... Stop after first error, failure, warning or, risky test + --stop-on-defect ... Stop after first error, failure, warning, or risky test --stop-on-error ..................................... Stop after first error --stop-on-failure ................................. Stop after first failure --stop-on-warning ................................. Stop after first warning --stop-on-risky ................................ Stop after first risky test + --stop-on-deprecation ... Stop after first test that triggered a deprecation + --stop-on-notice ............. Stop after first test that triggered a notice --stop-on-skipped ............................ Stop after first skipped test --stop-on-incomplete ...................... Stop after first incomplete test --fail-on-warning Signal failure using shell exit code when a warning was triggered --fail-on-risky Signal failure using shell exit code when a test was considered risky + --fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered + --fail-on-notice Signal failure using shell exit code when a notice was triggered --fail-on-skipped Signal failure using shell exit code when a test was skipped --fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete --cache-result ............................ Write test results to cache file diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 314ae733..469567e1 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -153,7 +153,7 @@ DEPR Tests\Features\Deprecated ! deprecated → str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated // tests/Features/Deprecated.php:6 - ! user deprecated → Since foo 1.0: This is a deprecation description // vendor/symfony/deprecation-contracts/function.php:25 + ✓ user deprecated PASS Tests\Features\Exceptions ✓ it gives access the the underlying expectException @@ -1016,4 +1016,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 709 passed (1717 assertions) + Tests: 1 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 710 passed (1717 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 8a354fe2..10f0d316 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -18,7 +18,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 697 passed (1702 assertions)') + ->toContain('Tests: 1 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 698 passed (1702 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();