mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 06:13:35 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17d709e32b | |||
| 46df02dc28 | |||
| fc17365bd1 |
@@ -234,9 +234,7 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
|
||||
$parts = explode('\\', $class);
|
||||
$current = &$tree;
|
||||
foreach ($parts as $part) {
|
||||
if (! isset($current[$part])) {
|
||||
$current[$part] = [];
|
||||
}
|
||||
$current[$part] ??= [];
|
||||
$current = &$current[$part];
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -1238,6 +1238,10 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
if (! $this->piggybackCoverage && ! in_array('--no-coverage', $arguments, true)) {
|
||||
$arguments[] = '--no-coverage';
|
||||
}
|
||||
|
||||
if (Parallel::isEnabled()) {
|
||||
$this->purgeWorkerPartials();
|
||||
|
||||
@@ -1501,7 +1505,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
|
||||
private function workerToken(): string
|
||||
{
|
||||
$raw = $_SERVER['TEST_TOKEN'] ?? $_ENV['TEST_TOKEN'] ?? null;
|
||||
$raw = $_SERVER['UNIQUE_TEST_TOKEN'] ?? $_ENV['UNIQUE_TEST_TOKEN']
|
||||
?? $_SERVER['TEST_TOKEN'] ?? $_ENV['TEST_TOKEN'] ?? null;
|
||||
|
||||
$token = is_scalar($raw) ? (string) $raw : (string) getmypid();
|
||||
$token = preg_replace('/[^A-Za-z0-9_-]/', '', $token);
|
||||
@@ -1532,9 +1537,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
|
||||
foreach (['files', 'tables', 'inertia'] as $section) {
|
||||
foreach ($data[$section] as $testFile => $values) {
|
||||
if (! isset($merged[$section][$testFile])) {
|
||||
$merged[$section][$testFile] = [];
|
||||
}
|
||||
$merged[$section][$testFile] ??= [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
$merged[$section][$testFile][$value] = true;
|
||||
|
||||
@@ -1020,9 +1020,7 @@ final class Graph
|
||||
|
||||
private function ensureBaseline(string $branch): void
|
||||
{
|
||||
if (! isset($this->baselines[$branch])) {
|
||||
$this->baselines[$branch] = ['sha' => null, 'tree' => [], 'results' => []];
|
||||
}
|
||||
$this->baselines[$branch] ??= ['sha' => null, 'tree' => [], 'results' => []];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1067,9 +1065,7 @@ final class Graph
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($this->edges[$rel])) {
|
||||
$this->edges[$rel] = [];
|
||||
}
|
||||
$this->edges[$rel] ??= [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -111,9 +111,7 @@ final class Preset
|
||||
*/
|
||||
private function baseNamespaces(): array
|
||||
{
|
||||
if (self::$baseNamespaces === null) {
|
||||
self::$baseNamespaces = Composer::userNamespaces();
|
||||
}
|
||||
self::$baseNamespaces ??= Composer::userNamespaces();
|
||||
|
||||
return self::$baseNamespaces;
|
||||
}
|
||||
|
||||
@@ -2061,6 +2061,10 @@
|
||||
✓ it accepts a page directory candidate only when it matches the casing on disk with ('wrong parent')
|
||||
✓ it accepts a page directory candidate only when it matches the casing on disk with ('absent')
|
||||
|
||||
PASS Tests\Unit\Plugins\Tia\WorkerToken
|
||||
✓ prefers the per-process UNIQUE_TEST_TOKEN over the per-slot TEST_TOKEN, so two workers recycled into the same slot get different tokens
|
||||
✓ falls back to TEST_TOKEN when UNIQUE_TEST_TOKEN is absent
|
||||
|
||||
PASS Tests\Unit\Preset
|
||||
✓ preset invalid name
|
||||
✓ preset → myFramework
|
||||
@@ -2251,4 +2255,4 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1596 passed (3481 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1598 passed (3485 assertions)
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Pest\Support\Coverage;
|
||||
use Tests\Fixtures\Tia\Project;
|
||||
|
||||
afterEach(function (): void {
|
||||
@@ -39,6 +40,44 @@ test('a plain run after a coverage run records the whole project scope', functio
|
||||
->and($graph['files'])->toContain('app/Calculator.php');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('xml-configured coverage does not prevent tia recording', function (): void {
|
||||
$project = Project::make('master');
|
||||
|
||||
$project->write('phpunit.xml', <<<'XML_WRAP'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
colors="true"
|
||||
failOnRisky="true"
|
||||
failOnWarning="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<report>
|
||||
<clover outputFile="coverage/clover.xml" />
|
||||
</report>
|
||||
</coverage>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
||||
XML_WRAP);
|
||||
|
||||
$result = $project->pest('--tia');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($project->graphExists())->toBeTrue()
|
||||
->and(array_keys($project->graph()['edges']))->toEqualCanonicalizing(array_keys(Project::EDGES));
|
||||
})->skipOnWindows()->skip(! Coverage::isAvailable(), 'Coverage is not available');
|
||||
|
||||
test('a coverage report leaves the edges of an existing graph alone', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Pest\Plugins\Tia;
|
||||
|
||||
function tiaWorkerToken(): string
|
||||
{
|
||||
$tia = new ReflectionClass(Tia::class)->newInstanceWithoutConstructor();
|
||||
|
||||
return new ReflectionMethod($tia, 'workerToken')->invoke($tia);
|
||||
}
|
||||
|
||||
beforeEach(function (): void {
|
||||
unset(
|
||||
$_SERVER['TEST_TOKEN'],
|
||||
$_ENV['TEST_TOKEN'],
|
||||
$_SERVER['UNIQUE_TEST_TOKEN'],
|
||||
$_ENV['UNIQUE_TEST_TOKEN'],
|
||||
);
|
||||
});
|
||||
|
||||
test('prefers the per-process UNIQUE_TEST_TOKEN over the per-slot TEST_TOKEN, so two workers recycled into the same slot get different tokens', function (): void {
|
||||
$_SERVER['TEST_TOKEN'] = '2';
|
||||
|
||||
$_SERVER['UNIQUE_TEST_TOKEN'] = '2_6a690d236824c';
|
||||
$processA = tiaWorkerToken();
|
||||
|
||||
$_SERVER['UNIQUE_TEST_TOKEN'] = '2_9f31be04117a';
|
||||
$processB = tiaWorkerToken();
|
||||
|
||||
expect($processA)->toBe('2_6a690d236824c')
|
||||
->and($processB)->toBe('2_9f31be04117a')
|
||||
->and($processA)->not->toBe($processB);
|
||||
});
|
||||
|
||||
test('falls back to TEST_TOKEN when UNIQUE_TEST_TOKEN is absent', function (): void {
|
||||
$_SERVER['TEST_TOKEN'] = '3';
|
||||
|
||||
expect(tiaWorkerToken())->toBe('3');
|
||||
});
|
||||
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
|
||||
$output = $run('--exclude-group=integration');
|
||||
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
|
||||
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1578 passed (3426 assertions)';
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1580 passed (3430 assertions)';
|
||||
|
||||
expect($output)
|
||||
->toContain("Tests: {$expected}")
|
||||
|
||||
Reference in New Issue
Block a user