mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83baa5de2f | |||
| 0a2a6e9f0f | |||
| 9714c8553f | |||
| 14a3efd918 | |||
| 8b6607e344 | |||
| 94f4f1ff48 | |||
| f0dd0d4d85 | |||
| 4b4474dd77 | |||
| 942d6aead1 | |||
| 7cdebc6a95 | |||
| c9c3a8c34a | |||
| 06400e721e | |||
| c42a2719e4 | |||
| 2440001cfc |
+10
-3
@@ -1,7 +1,14 @@
|
||||
# The intention of this project
|
||||
|
||||
Write the intention of the project here. Say what the project does and who uses it.
|
||||
Pest is a testing framework for PHP with a focus on simplicity. A PHP developer uses it to write the tests of an application or of a package, and an AI agent reads its output. It is a package, and `src/Functions.php` holds its public API.
|
||||
|
||||
Give the command that installs the dependencies, the command that runs the tests and the command that starts the program. Name each directory and give its function.
|
||||
Install the dependencies with `composer install`. Run the tests with `composer test`. Start the program with `./bin/pest`.
|
||||
|
||||
Write a decision that one directory needs in the `AGENTS.md` file of that directory.
|
||||
- `src/` — the framework: the plugins, the expectation API, the test case and the console output
|
||||
- `bin/` — the executable `pest` and the worker of the parallel runner
|
||||
- `overrides/` — the classes of PHPUnit that Pest replaces, which `src/Bootstrappers/BootOverrides.php` loads at boot
|
||||
- `resources/` — the views of the console output and the base configuration of PHPUnit
|
||||
- `stubs/` — the files that `pest --init` writes into a project
|
||||
- `tests/` — the tests of the framework, in Pest itself
|
||||
- `tests-external/` — the tests that must sit outside `tests/`
|
||||
- `docker/` — the image that runs the tests on one version of PHP
|
||||
|
||||
@@ -1,12 +1,32 @@
|
||||
1a51f3f6c4eef45e6995bb5ac9a82cf3f23ccad0c68cc4f957796bb9fc198f58 .agents/skills/deps-upgrade/SKILL.md
|
||||
8fee50af5e8d9ff55db278de9701b10e11dfef6eecfc4127f2608c85f0f0fdd1 .agents/skills/code-immutability/SKILL.md
|
||||
d489e18e5863e814795f5674a58f507e98fbbeb341a218dbd5bc9173d39554d3 .agents/skills/code-immutability/agents/openai.yaml
|
||||
0c47a67a1bcb590b057984fa4e9c4704fb3485652864f3e5ac6a3ba8200e74f4 .agents/skills/code-messages/SKILL.md
|
||||
fc01d0c81e189623e6e7c912498f46f63f489bbe59967cccde742ea2c4e31b5a .agents/skills/code-messages/agents/openai.yaml
|
||||
3d39b47c159c0bbdc413781afe12cdb9fcad4086d4810a6c11dfd0c909d90e81 .agents/skills/code-quality/SKILL.md
|
||||
f47191e1bad34e547d1b3ee3ae111c417c383ec5459d467bfae5e832d86275c9 .agents/skills/code-quality/agents/openai.yaml
|
||||
9d5e921bdfa05ef955657d59702e79a83b44853c075d513793bb76a7f479004f .agents/skills/code-slop/SKILL.md
|
||||
520a3834948850bf7e2232d92341f07ff7bfc9e67247818b56fb576ca6dbf169 .agents/skills/code-slop/agents/openai.yaml
|
||||
2f9d68ed1b93eb74bc1c23cad34a88b765bd0ab306faacab1105d9489ede8ad1 .agents/skills/code-tooling/SKILL.md
|
||||
868c67118e15aa9eb8f4ee35228fc2d04b1c0cf129ee3fec9177113a77f5863e .agents/skills/code-tooling/agents/openai.yaml
|
||||
5df241fc65e271c93d13708f868f9a624669bcfc06b3d84af9cf6fce03a25558 .agents/skills/deps-upgrade/SKILL.md
|
||||
984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .agents/skills/deps-upgrade/agents/openai.yaml
|
||||
e68fb750f54ca3b17d6797954cb7838f0415c2faa65496ae68cb3918474c68bf .agents/skills/init/SKILL.md
|
||||
275df9900027499c1ab97ab2675b2992e4267559bd61933a637d6a15d25a9350 .agents/skills/init/SKILL.md
|
||||
14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .agents/skills/init/agents/openai.yaml
|
||||
3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .agents/skills/snapshots-update/SKILL.md
|
||||
bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .agents/skills/snapshots-update/agents/openai.yaml
|
||||
1a51f3f6c4eef45e6995bb5ac9a82cf3f23ccad0c68cc4f957796bb9fc198f58 .claude/skills/deps-upgrade/SKILL.md
|
||||
8fee50af5e8d9ff55db278de9701b10e11dfef6eecfc4127f2608c85f0f0fdd1 .claude/skills/code-immutability/SKILL.md
|
||||
d489e18e5863e814795f5674a58f507e98fbbeb341a218dbd5bc9173d39554d3 .claude/skills/code-immutability/agents/openai.yaml
|
||||
0c47a67a1bcb590b057984fa4e9c4704fb3485652864f3e5ac6a3ba8200e74f4 .claude/skills/code-messages/SKILL.md
|
||||
fc01d0c81e189623e6e7c912498f46f63f489bbe59967cccde742ea2c4e31b5a .claude/skills/code-messages/agents/openai.yaml
|
||||
3d39b47c159c0bbdc413781afe12cdb9fcad4086d4810a6c11dfd0c909d90e81 .claude/skills/code-quality/SKILL.md
|
||||
f47191e1bad34e547d1b3ee3ae111c417c383ec5459d467bfae5e832d86275c9 .claude/skills/code-quality/agents/openai.yaml
|
||||
9d5e921bdfa05ef955657d59702e79a83b44853c075d513793bb76a7f479004f .claude/skills/code-slop/SKILL.md
|
||||
520a3834948850bf7e2232d92341f07ff7bfc9e67247818b56fb576ca6dbf169 .claude/skills/code-slop/agents/openai.yaml
|
||||
2f9d68ed1b93eb74bc1c23cad34a88b765bd0ab306faacab1105d9489ede8ad1 .claude/skills/code-tooling/SKILL.md
|
||||
868c67118e15aa9eb8f4ee35228fc2d04b1c0cf129ee3fec9177113a77f5863e .claude/skills/code-tooling/agents/openai.yaml
|
||||
5df241fc65e271c93d13708f868f9a624669bcfc06b3d84af9cf6fce03a25558 .claude/skills/deps-upgrade/SKILL.md
|
||||
984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .claude/skills/deps-upgrade/agents/openai.yaml
|
||||
e68fb750f54ca3b17d6797954cb7838f0415c2faa65496ae68cb3918474c68bf .claude/skills/init/SKILL.md
|
||||
275df9900027499c1ab97ab2675b2992e4267559bd61933a637d6a15d25a9350 .claude/skills/init/SKILL.md
|
||||
14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .claude/skills/init/agents/openai.yaml
|
||||
3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .claude/skills/snapshots-update/SKILL.md
|
||||
bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .claude/skills/snapshots-update/agents/openai.yaml
|
||||
|
||||
+9
-9
@@ -18,20 +18,20 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.4",
|
||||
"brianium/paratest": "^7.24.1",
|
||||
"brianium/paratest": "^7.26.0",
|
||||
"nunomaduro/collision": "^8.9.5",
|
||||
"nunomaduro/termwind": "^2.4.0",
|
||||
"pestphp/pest-plugin": "^5.0.0",
|
||||
"pestphp/pest-plugin-arch": "^5.0.0",
|
||||
"pestphp/pest-plugin-mutate": "^5.0.2",
|
||||
"pestphp/pest-plugin-profanity": "^5.0.0",
|
||||
"phpunit/phpunit": "^13.3.2",
|
||||
"symfony/process": "^8.1.6"
|
||||
"pestphp/pest-plugin-profanity": "^5.0.1",
|
||||
"phpunit/phpunit": "^13.4.1",
|
||||
"symfony/process": "^8.1.7"
|
||||
},
|
||||
"conflict": {
|
||||
"filp/whoops": "<2.18.3",
|
||||
"laravel/boost": "<2.6.0",
|
||||
"phpunit/phpunit": ">13.3.2",
|
||||
"phpunit/phpunit": ">13.4.1",
|
||||
"sebastian/exporter": "<7.0.0",
|
||||
"webmozart/assert": "<1.11.0"
|
||||
},
|
||||
@@ -61,10 +61,10 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest-dev-tools": "^5.0.0",
|
||||
"pestphp/pest-plugin-browser": "^5.0.1",
|
||||
"pestphp/pest-plugin-phpstan": "^5.2.1",
|
||||
"pestphp/pest-plugin-rector": "^5.0.4",
|
||||
"pestphp/pest-plugin-type-coverage": "^5.0.2",
|
||||
"pestphp/pest-plugin-browser": "^5.1.2",
|
||||
"pestphp/pest-plugin-phpstan": "^5.2.2",
|
||||
"pestphp/pest-plugin-rector": "^5.0.5",
|
||||
"pestphp/pest-plugin-type-coverage": "^5.0.3",
|
||||
"psy/psysh": "^0.12.24"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
|
||||
@@ -13,26 +13,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace PHPUnit\Runner;
|
||||
|
||||
use PHPUnit\Framework\DataProviderTestSuite;
|
||||
use PHPUnit\Framework\IterativeTestSuite;
|
||||
use PHPUnit\Framework\Reorderable;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Runner\ExecutionOrder\Context;
|
||||
use PHPUnit\Runner\ExecutionOrder\ReorderPipeline;
|
||||
use PHPUnit\Runner\TestRunHistory\NullTestRunHistory;
|
||||
use PHPUnit\Runner\TestRunHistory\TestRunHistory;
|
||||
use PHPUnit\Runner\TestRunHistory\TestRunHistoryId;
|
||||
|
||||
use function array_diff;
|
||||
use function array_merge;
|
||||
use function array_reverse;
|
||||
use function array_splice;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function max;
|
||||
use function shuffle;
|
||||
use function usort;
|
||||
|
||||
/**
|
||||
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||
@@ -55,20 +43,9 @@ final class TestSuiteSorter
|
||||
|
||||
public const int ORDER_SIZE_DESCENDING = 7;
|
||||
|
||||
/**
|
||||
* @var non-empty-array<non-empty-string, positive-int>
|
||||
*/
|
||||
private const array SIZE_SORT_WEIGHT = [
|
||||
'small' => 1,
|
||||
'medium' => 2,
|
||||
'large' => 3,
|
||||
'unknown' => 4,
|
||||
];
|
||||
public const int ORDER_MODIFIED_ASCENDING = 8;
|
||||
|
||||
/**
|
||||
* @var array<string, int> Associative array of (string => DEFECT_SORT_WEIGHT) elements
|
||||
*/
|
||||
private array $defectSortOrder = [];
|
||||
public const int ORDER_MODIFIED_DESCENDING = 9;
|
||||
|
||||
private readonly TestRunHistory $testRunHistory;
|
||||
|
||||
@@ -77,292 +54,41 @@ final class TestSuiteSorter
|
||||
$this->testRunHistory = $testRunHistory ?? new NullTestRunHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function reorderTestsInSuite(Test $suite, int $order, bool $resolveDependencies, int $orderDefects): void
|
||||
public function apply(Test $suite, ReorderPipeline $pipeline): void
|
||||
{
|
||||
$allowedOrders = [
|
||||
self::ORDER_DEFAULT,
|
||||
self::ORDER_REVERSED,
|
||||
self::ORDER_RANDOMIZED,
|
||||
self::ORDER_DURATION_ASCENDING,
|
||||
self::ORDER_SIZE_ASCENDING,
|
||||
self::ORDER_DURATION_DESCENDING,
|
||||
self::ORDER_SIZE_DESCENDING,
|
||||
];
|
||||
|
||||
if (! in_array($order, $allowedOrders, true)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new InvalidOrderException;
|
||||
// @codeCoverageIgnoreEnd
|
||||
if ($pipeline->describe() === ['resolve-dependencies'] && ! $this->anyTestHasDependencies([$suite])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$allowedOrderDefects = [
|
||||
self::ORDER_DEFAULT,
|
||||
self::ORDER_DEFECTS_FIRST,
|
||||
];
|
||||
|
||||
if (! in_array($orderDefects, $allowedOrderDefects, true)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new InvalidOrderException;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
$this->applyRecursively($suite, $pipeline);
|
||||
}
|
||||
|
||||
private function applyRecursively(Test $suite, ReorderPipeline $pipeline): void
|
||||
{
|
||||
if ($suite instanceof IterativeTestSuite) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($suite instanceof TestSuite) {
|
||||
foreach ($suite as $_suite) {
|
||||
$this->reorderTestsInSuite($_suite, $order, $resolveDependencies, $orderDefects);
|
||||
}
|
||||
if (! $suite instanceof TestSuite) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
|
||||
$this->addSuiteToDefectSortOrder($suite);
|
||||
}
|
||||
|
||||
$this->sort($suite, $order, $resolveDependencies, $orderDefects);
|
||||
foreach ($suite as $child) {
|
||||
$this->applyRecursively($child, $pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
private function sort(TestSuite $suite, int $order, bool $resolveDependencies, int $orderDefects): void
|
||||
{
|
||||
$tests = $suite->tests();
|
||||
|
||||
if ($tests === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($order === self::ORDER_REVERSED) {
|
||||
$tests = $this->reverse($tests);
|
||||
} elseif ($order === self::ORDER_RANDOMIZED) {
|
||||
$tests = $this->randomize($tests);
|
||||
} elseif ($order === self::ORDER_DURATION_ASCENDING) {
|
||||
$tests = $this->sortByDuration($tests);
|
||||
} elseif ($order === self::ORDER_DURATION_DESCENDING) {
|
||||
$tests = $this->sortByDurationDescending($tests);
|
||||
} elseif ($order === self::ORDER_SIZE_ASCENDING) {
|
||||
$tests = $this->sortBySize($tests);
|
||||
} elseif ($order === self::ORDER_SIZE_DESCENDING) {
|
||||
$tests = $this->sortBySizeDescending($tests);
|
||||
}
|
||||
|
||||
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
|
||||
$tests = $this->sortDefectsFirst($tests);
|
||||
}
|
||||
|
||||
if ($resolveDependencies && ! ($suite instanceof DataProviderTestSuite)) {
|
||||
/** @noinspection PhpParamsInspection */
|
||||
/** @phpstan-ignore argument.type */
|
||||
$tests = $this->resolveDependencies($tests);
|
||||
}
|
||||
|
||||
$suite->setTests($tests);
|
||||
}
|
||||
|
||||
private function addSuiteToDefectSortOrder(TestSuite $suite): void
|
||||
{
|
||||
$max = 0;
|
||||
|
||||
foreach ($suite->tests() as $test) {
|
||||
assert($test instanceof Reorderable);
|
||||
|
||||
$sortId = $test->sortId();
|
||||
|
||||
if (! isset($this->defectSortOrder[$sortId])) {
|
||||
$this->defectSortOrder[$sortId] = $this->testRunHistory->status(TestRunHistoryId::fromReorderable($test))->sortWeight();
|
||||
}
|
||||
|
||||
$max = max($max, $this->defectSortOrder[$sortId]);
|
||||
}
|
||||
|
||||
$this->defectSortOrder[$suite->sortId()] = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function reverse(array $tests): array
|
||||
{
|
||||
return array_reverse($tests);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function randomize(array $tests): array
|
||||
{
|
||||
shuffle($tests);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function sortDefectsFirst(array $tests): array
|
||||
{
|
||||
usort(
|
||||
$tests,
|
||||
fn (Test $left, Test $right) => $this->cmpDefectPriorityAndTime($left, $right),
|
||||
$suite->setTests(
|
||||
$pipeline->apply(
|
||||
$tests,
|
||||
new Context($suite, $this->testRunHistory),
|
||||
),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function sortByDuration(array $tests): array
|
||||
{
|
||||
usort(
|
||||
$tests,
|
||||
fn (Test $left, Test $right) => $this->cmpDuration($left, $right),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function sortByDurationDescending(array $tests): array
|
||||
{
|
||||
usort(
|
||||
$tests,
|
||||
fn (Test $left, Test $right) => $this->cmpDuration($right, $left),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function sortBySize(array $tests): array
|
||||
{
|
||||
usort(
|
||||
$tests,
|
||||
fn (Test $left, Test $right) => $this->cmpSize($left, $right),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Test> $tests
|
||||
* @return list<Test>
|
||||
*/
|
||||
private function sortBySizeDescending(array $tests): array
|
||||
{
|
||||
usort(
|
||||
$tests,
|
||||
fn (Test $left, Test $right) => $this->cmpSize($right, $left),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
private function cmpDefectPriorityAndTime(Test $a, Test $b): int
|
||||
{
|
||||
assert($a instanceof Reorderable);
|
||||
assert($b instanceof Reorderable);
|
||||
|
||||
$priorityA = $this->defectSortOrder[$a->sortId()] ?? 0;
|
||||
$priorityB = $this->defectSortOrder[$b->sortId()] ?? 0;
|
||||
|
||||
return $priorityB <=> $priorityA;
|
||||
}
|
||||
|
||||
private function cmpDuration(Test $a, Test $b): int
|
||||
{
|
||||
return $this->durationWeight($a) <=> $this->durationWeight($b);
|
||||
}
|
||||
|
||||
private function durationWeight(Test $test): float
|
||||
{
|
||||
if ($test instanceof TestSuite) {
|
||||
$sum = 0.0;
|
||||
|
||||
foreach ($test->tests() as $inner) {
|
||||
$sum += $this->durationWeight($inner);
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
if ($test instanceof Reorderable) {
|
||||
return $this->testRunHistory->time(TestRunHistoryId::fromReorderable($test));
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
private function cmpSize(Test $a, Test $b): int
|
||||
{
|
||||
return $this->sizeWeight($a) <=> $this->sizeWeight($b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return positive-int
|
||||
*/
|
||||
private function sizeWeight(Test $test): int
|
||||
{
|
||||
if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) {
|
||||
return self::SIZE_SORT_WEIGHT[$test->size()->asString()];
|
||||
}
|
||||
|
||||
if ($test instanceof TestSuite) {
|
||||
$max = 0;
|
||||
|
||||
foreach ($test->tests() as $inner) {
|
||||
$weight = $this->sizeWeight($inner);
|
||||
|
||||
if ($weight > $max) {
|
||||
$max = $weight;
|
||||
}
|
||||
}
|
||||
|
||||
if ($max > 0) {
|
||||
return $max;
|
||||
}
|
||||
}
|
||||
|
||||
return self::SIZE_SORT_WEIGHT['unknown'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<TestCase> $tests
|
||||
* @return list<TestCase>
|
||||
*/
|
||||
private function resolveDependencies(array $tests): array
|
||||
{
|
||||
if (! $this->anyTestHasDependencies($tests)) {
|
||||
return $tests;
|
||||
}
|
||||
|
||||
$newTestOrder = [];
|
||||
$i = 0;
|
||||
$provided = [];
|
||||
|
||||
while ($tests !== [] && $i < count($tests)) {
|
||||
if (array_diff($tests[$i]->requires(), $provided) === []) {
|
||||
$provided = array_merge($provided, $tests[$i]->provides());
|
||||
$newTestOrder = array_merge($newTestOrder, array_splice($tests, $i, 1));
|
||||
$i = 0;
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($newTestOrder, $tests);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ use Pest\Plugins\Only;
|
||||
use Pest\Runner\Filter\EnsureTestCaseIsInitiatedFilter;
|
||||
use PHPUnit\Event;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Metadata\Api\Groups;
|
||||
use PHPUnit\Runner\Filter\Factory;
|
||||
use PHPUnit\TextUI\Configuration\Configuration;
|
||||
use PHPUnit\TextUI\Configuration\FilterNotConfiguredException;
|
||||
@@ -27,6 +28,8 @@ use function array_map;
|
||||
*/
|
||||
final readonly class TestSuiteFilterProcessor
|
||||
{
|
||||
public function __construct(private Event\Emitter $emitter) {}
|
||||
|
||||
/**
|
||||
* @throws Event\RuntimeException
|
||||
* @throws FilterNotConfiguredException
|
||||
@@ -70,7 +73,7 @@ final readonly class TestSuiteFilterProcessor
|
||||
if ($configuration->hasTestsCovering()) {
|
||||
$factory->addIncludeGroupFilter(
|
||||
array_map(
|
||||
static fn (string $name): string => '__phpunit_covers_'.$name,
|
||||
Groups::virtualGroupForCovers(...),
|
||||
$configuration->testsCovering(),
|
||||
),
|
||||
);
|
||||
@@ -79,7 +82,7 @@ final readonly class TestSuiteFilterProcessor
|
||||
if ($configuration->hasTestsUsing()) {
|
||||
$factory->addIncludeGroupFilter(
|
||||
array_map(
|
||||
static fn (string $name): string => '__phpunit_uses_'.$name,
|
||||
Groups::virtualGroupForUses(...),
|
||||
$configuration->testsUsing(),
|
||||
),
|
||||
);
|
||||
@@ -99,7 +102,7 @@ final readonly class TestSuiteFilterProcessor
|
||||
|
||||
$suite->injectFilter($factory);
|
||||
|
||||
Event\Facade::emitter()->testSuiteFiltered(
|
||||
$this->emitter->testSuiteFiltered(
|
||||
Event\TestSuite\TestSuiteBuilder::from($suite),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ trait Testable
|
||||
|
||||
TestSuite::getInstance()->snapshots->forget();
|
||||
|
||||
Closure::bind(fn (): array => $this->mockObjects = [], $this, TestCase::class)();
|
||||
Closure::bind(fn () => $this->mockObjectRegistry->clear(), $this, TestCase::class)();
|
||||
|
||||
foreach (array_keys(array_diff_key(get_object_vars($this), $initialProperties)) as $property) {
|
||||
unset($this->{$property});
|
||||
|
||||
@@ -187,8 +187,8 @@ final class TestCaseMethodFactory
|
||||
$attributesCode
|
||||
public function $methodName(...\$arguments)
|
||||
{
|
||||
if (count(\$arguments) === 1 && \$arguments[0] instanceof __PestDatasetProviderError) {
|
||||
throw \$arguments[0]->getPrevious() ?? \$arguments[0];
|
||||
if (count(\$arguments) === 1 && \$arguments[array_key_first(\$arguments)] instanceof __PestDatasetProviderError) {
|
||||
throw \$arguments[array_key_first(\$arguments)]->getPrevious() ?? \$arguments[array_key_first(\$arguments)];
|
||||
}
|
||||
|
||||
return \$this->__runTest(
|
||||
|
||||
+7
-1
@@ -29,6 +29,8 @@ use Whoops\Exception\Inspector;
|
||||
*/
|
||||
final class Kernel
|
||||
{
|
||||
private bool $booted = false;
|
||||
|
||||
private bool $terminated = false;
|
||||
|
||||
/**
|
||||
@@ -81,6 +83,8 @@ final class Kernel
|
||||
|
||||
CallsBoot::execute();
|
||||
|
||||
$kernel->booted = true;
|
||||
|
||||
Container::getInstance()->add(self::class, $kernel);
|
||||
|
||||
return $kernel;
|
||||
@@ -132,7 +136,9 @@ final class Kernel
|
||||
|
||||
$preBufferOutput->terminate();
|
||||
|
||||
CallsTerminable::execute();
|
||||
if ($this->booted) {
|
||||
CallsTerminable::execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function shutdown(): void
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '5.1.4';
|
||||
return '5.3.1';
|
||||
}
|
||||
|
||||
function testDirectory(string $file = ''): string
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Pest\Plugins;
|
||||
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use PHPUnit\Event\Facade as EventFacade;
|
||||
use PHPUnit\TextUI\CliArguments\Builder as CliConfigurationBuilder;
|
||||
use PHPUnit\TextUI\CliArguments\XmlConfigurationFileFinder;
|
||||
use PHPUnit\TextUI\XmlConfiguration\DefaultConfiguration;
|
||||
@@ -30,12 +31,12 @@ final class Cache implements HandlesArguments
|
||||
{
|
||||
if (! $this->hasArgument('--cache-directory', $arguments)) {
|
||||
|
||||
$cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]);
|
||||
$cliConfiguration = new CliConfigurationBuilder(EventFacade::emitter())->fromParameters([]);
|
||||
$configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration);
|
||||
$xmlConfiguration = DefaultConfiguration::create();
|
||||
|
||||
if (is_string($configurationFile)) {
|
||||
$xmlConfiguration = (new Loader)->load($configurationFile);
|
||||
$xmlConfiguration = new Loader(EventFacade::emitter())->load($configurationFile);
|
||||
}
|
||||
|
||||
if (! $xmlConfiguration->phpunit()->hasCacheDirectory()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ use DOMDocument;
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Contracts\Plugins\Terminable;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use PHPUnit\Event\Facade as EventFacade;
|
||||
use PHPUnit\TextUI\CliArguments\Builder as CliConfigurationBuilder;
|
||||
use PHPUnit\TextUI\CliArguments\XmlConfigurationFileFinder;
|
||||
|
||||
@@ -56,7 +57,7 @@ final class Configuration implements HandlesArguments, Terminable
|
||||
|
||||
private function hasCustomConfigurationFile(): bool
|
||||
{
|
||||
$cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]);
|
||||
$cliConfiguration = new CliConfigurationBuilder(EventFacade::emitter())->fromParameters([]);
|
||||
$configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration);
|
||||
|
||||
return is_string($configurationFile);
|
||||
|
||||
+2
-10
@@ -20,13 +20,8 @@ final readonly class Help implements HandlesArguments
|
||||
|
||||
public function __construct(
|
||||
private OutputInterface $output
|
||||
) {
|
||||
//
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function handleArguments(array $arguments): array
|
||||
{
|
||||
if ($this->hasArgument('--help', $arguments)) {
|
||||
@@ -56,8 +51,6 @@ final readonly class Help implements HandlesArguments
|
||||
'desc' => $description,
|
||||
] = $option;
|
||||
|
||||
assert(is_string($argument));
|
||||
|
||||
if (trim($argument) === '--process-isolation') {
|
||||
continue;
|
||||
}
|
||||
@@ -87,13 +80,12 @@ final readonly class Help implements HandlesArguments
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, array<'arg'|'desc'|int, array{arg: string, desc: string}|string>>>
|
||||
* @return array<non-empty-string, non-empty-list<array{}|array{arg: non-empty-string, desc: non-empty-string}|array{spacer: ''}|array{text: non-empty-string}>>
|
||||
*/
|
||||
private function getContent(): array
|
||||
{
|
||||
$helpReflection = new PHPUnitHelp;
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
$content = (fn (): array => $this->elements())->call($helpReflection);
|
||||
|
||||
$content['Configuration'] = [...[[
|
||||
|
||||
@@ -369,7 +369,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
$failedEvents = array_merge_recursive($testResultSum->testFailedEvents(), $testResult->testFailedEvents());
|
||||
|
||||
$testResultSum = new TestResult(
|
||||
(int) $testResultSum->hasTests() + (int) $testResult->hasTests(),
|
||||
ResultReflection::numberOfTests($testResultSum) + self::numberOfTestsSeenByWorker($testResult),
|
||||
$testResultSum->numberOfTestsRun() + $testResult->numberOfTestsRun(),
|
||||
$testResultSum->numberOfAssertions() + $testResult->numberOfAssertions(),
|
||||
array_merge_recursive($testResultSum->testErroredEvents(), $testResult->testErroredEvents()),
|
||||
@@ -500,6 +500,11 @@ final class WrapperRunner implements RunnerInterface
|
||||
return $exitcode;
|
||||
}
|
||||
|
||||
private static function numberOfTestsSeenByWorker(TestResult $result): int
|
||||
{
|
||||
return max(ResultReflection::numberOfTests($result), $result->numberOfTestsRun());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{self: non-negative-int, direct: non-negative-int, indirect: non-negative-int, unknown: non-negative-int}
|
||||
*/
|
||||
@@ -542,7 +547,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
throw MissingResultsException::create($missingCoverageFiles, 'coverage');
|
||||
}
|
||||
|
||||
$coverageManager = new CodeCoverage;
|
||||
$coverageManager = new CodeCoverage(EventFacade::emitter());
|
||||
$coverageManager->init(
|
||||
$this->options->configuration,
|
||||
$this->codeCoverageFilterRegistry,
|
||||
|
||||
@@ -206,7 +206,7 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
|
||||
{
|
||||
$filtered = $this->removeParallelArguments($arguments);
|
||||
|
||||
return ['php', ...$filtered, '--test-directory='.$testPath, '--list-tests'];
|
||||
return [PHP_BINARY, ...$filtered, '--test-directory='.$testPath, '--list-tests'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Pest\Plugins;
|
||||
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Support\Ci;
|
||||
use Pest\TestSuite;
|
||||
|
||||
/**
|
||||
@@ -16,34 +17,9 @@ final class Snapshot implements HandlesArguments
|
||||
|
||||
public static bool $updateSnapshots = false;
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private const array CI_ENVIRONMENT_VARIABLES = [
|
||||
'CI',
|
||||
'GITHUB_ACTIONS',
|
||||
'GITLAB_CI',
|
||||
'CIRCLECI',
|
||||
'TRAVIS',
|
||||
'APPVEYOR',
|
||||
'BITBUCKET_BUILD_NUMBER',
|
||||
'BUILDKITE',
|
||||
'TEAMCITY_VERSION',
|
||||
'JENKINS_URL',
|
||||
'SYSTEM_COLLECTIONURI',
|
||||
'CI_NAME',
|
||||
'TASKCLUSTER_ROOT_URL',
|
||||
'DRONE',
|
||||
'WERCKER',
|
||||
'NEVERCODE',
|
||||
'SEMAPHORE',
|
||||
'NETLIFY',
|
||||
'NOW_BUILDER',
|
||||
];
|
||||
|
||||
public static function shouldCreateMissingSnapshots(): bool
|
||||
{
|
||||
return self::$updateSnapshots || ! self::runningOnCI();
|
||||
return self::$updateSnapshots || ! Ci::isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,13 +125,4 @@ final class Snapshot implements HandlesArguments
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function runningOnCI(): bool
|
||||
{
|
||||
if (Environment::name() === Environment::CI) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return array_any(self::CI_ENVIRONMENT_VARIABLES, fn (string $environmentVariable): bool => getenv($environmentVariable) !== false);
|
||||
}
|
||||
}
|
||||
|
||||
+51
-20
@@ -20,7 +20,7 @@ use Pest\Panic;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use Pest\Plugins\Tia\BaselineSync;
|
||||
use Pest\Plugins\Tia\ChangedFiles;
|
||||
use Pest\Plugins\Tia\CiDefaultBranch;
|
||||
use Pest\Plugins\Tia\CiBranch;
|
||||
use Pest\Plugins\Tia\Contracts\State;
|
||||
use Pest\Plugins\Tia\CoverageCollector;
|
||||
use Pest\Plugins\Tia\Fingerprint;
|
||||
@@ -196,8 +196,6 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
|
||||
private bool $unreadableGraphReported = false;
|
||||
|
||||
private bool $detachedHead = false;
|
||||
|
||||
private bool $graphUnreachable = false;
|
||||
|
||||
private bool $fullSuiteFallbackRan = false;
|
||||
@@ -283,19 +281,11 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
|
||||
private function deleteState(string $key): bool
|
||||
{
|
||||
if ($this->detachedHead) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->state->delete($key);
|
||||
}
|
||||
|
||||
private function saveGraph(Graph $graph): bool
|
||||
{
|
||||
if ($this->detachedHead) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$json = $graph->encode();
|
||||
|
||||
if ($json === null) {
|
||||
@@ -793,8 +783,10 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return $this->reconcileFingerprint($rebuilt, $current);
|
||||
}
|
||||
|
||||
$this->deleteState(self::KEY_GRAPH);
|
||||
$this->deleteState(self::KEY_COVERAGE_CACHE);
|
||||
if ($this->canRebuildGraph()) {
|
||||
$this->deleteState(self::KEY_GRAPH);
|
||||
$this->deleteState(self::KEY_COVERAGE_CACHE);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -851,8 +843,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
$fingerprint = Fingerprint::compute($projectRoot);
|
||||
$this->startFingerprint = $fingerprint;
|
||||
|
||||
if ($forceRebuild && ! $this->detachedHead) {
|
||||
Storage::purge($projectRoot);
|
||||
if ($forceRebuild && $this->canRebuildGraph()) {
|
||||
$this->purgeState();
|
||||
}
|
||||
|
||||
$graph = ($forceRebuild || $this->forceRefetch) ? null : $this->loadGraph($projectRoot);
|
||||
@@ -912,6 +904,29 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return $this->enterRecordMode($arguments);
|
||||
}
|
||||
|
||||
private function purgeState(): void
|
||||
{
|
||||
foreach ([
|
||||
self::KEY_GRAPH,
|
||||
self::KEY_AFFECTED,
|
||||
self::KEY_COVERAGE_CACHE,
|
||||
self::KEY_COVERAGE_MARKER,
|
||||
self::KEY_FETCH_COOLDOWN,
|
||||
] as $key) {
|
||||
$this->state->delete($key);
|
||||
}
|
||||
|
||||
foreach ([
|
||||
self::KEY_WORKER_EDGES_PREFIX,
|
||||
self::KEY_WORKER_RESULTS_PREFIX,
|
||||
self::KEY_WORKER_NO_DRIVER_PREFIX,
|
||||
] as $prefix) {
|
||||
foreach ($this->state->keysWithPrefix($prefix) as $key) {
|
||||
$this->state->delete($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $arguments
|
||||
* @return array<int, string>
|
||||
@@ -1233,6 +1248,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
$recorder = $this->recorder;
|
||||
|
||||
if (! $this->piggybackCoverage && ! $recorder->driverAvailable()) {
|
||||
$this->requestWorkerResults();
|
||||
$this->emitCoverageDriverMissing();
|
||||
|
||||
return $arguments;
|
||||
@@ -1282,6 +1298,11 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
private function canRebuildGraph(): bool
|
||||
{
|
||||
return ! $this->piggybackCoverage && $this->recorder->driverAvailable();
|
||||
}
|
||||
|
||||
private function renderFreshGraph(): void
|
||||
{
|
||||
if ($this->driftLabel === null && $this->freshGraphReason !== null) {
|
||||
@@ -1948,10 +1969,17 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
|
||||
Parallel::setGlobal(self::FALLBACK_BRANCH_GLOBAL, $this->fallbackBranch);
|
||||
|
||||
$currentBranch = $changedFiles->currentBranch();
|
||||
$this->branch = $changedFiles->currentBranch()
|
||||
?? CiBranch::detectCurrent()
|
||||
?? $this->workspaceBranch($projectRoot);
|
||||
}
|
||||
|
||||
$this->detachedHead = $currentBranch === null;
|
||||
$this->branch = $currentBranch ?? $this->fallbackBranch;
|
||||
private function workspaceBranch(string $projectRoot): string
|
||||
{
|
||||
$realProjectRoot = realpath($projectRoot);
|
||||
$hash = hash('sha256', $realProjectRoot === false ? $projectRoot : $realProjectRoot);
|
||||
|
||||
return Graph::WORKSPACE_BRANCH_PREFIX.substr($hash, 0, 16);
|
||||
}
|
||||
|
||||
private function resolveFallbackBranch(ChangedFiles $changedFiles): ?string
|
||||
@@ -1963,7 +1991,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
}
|
||||
|
||||
return $this->watchPatterns->defaultBranch()
|
||||
?? CiDefaultBranch::detect()
|
||||
?? CiBranch::detectDefault()
|
||||
?? $changedFiles->defaultBranch()
|
||||
?? $this->soleRecordedBranch();
|
||||
}
|
||||
@@ -1976,7 +2004,10 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
$branches = Graph::branchesIn($json);
|
||||
$branches = array_values(array_filter(
|
||||
Graph::branchesIn($json),
|
||||
fn (string $branch): bool => ! str_starts_with($branch, Graph::WORKSPACE_BRANCH_PREFIX),
|
||||
));
|
||||
|
||||
return count($branches) === 1 ? $branches[0] : null;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ namespace Pest\Plugins\Tia;
|
||||
use Pest\Exceptions\BaselineFetchFailed;
|
||||
use Pest\Panic;
|
||||
use Pest\Plugins\Tia;
|
||||
use Pest\Plugins\Tia\Baselines\BaseRemote;
|
||||
use Pest\Plugins\Tia\Contracts\State;
|
||||
use Pest\Support\Ci;
|
||||
use Pest\Support\View;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
@@ -17,10 +19,6 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
final readonly class BaselineSync
|
||||
{
|
||||
private const string DEFAULT_WORKFLOW_FILE = 'tia-baseline.yml';
|
||||
|
||||
private const string ARTIFACT_NAME = 'pest-tia-baseline';
|
||||
|
||||
private const string GRAPH_ASSET = Tia::KEY_GRAPH;
|
||||
|
||||
private const string COVERAGE_ASSET = Tia::KEY_COVERAGE_CACHE;
|
||||
@@ -31,27 +29,12 @@ final readonly class BaselineSync
|
||||
|
||||
private const int FETCH_COOLDOWN_SECONDS = 86400;
|
||||
|
||||
private const array DIAGNOSES = [
|
||||
'network' => [
|
||||
'pattern' => '/could not resolve host|connection refused|connection reset|temporary failure in name resolution|network is unreachable|no route to host|i\/o timeout|tls handshake|getaddrinfo/i',
|
||||
'message' => 'network error (offline or DNS unreachable). Try again when connected.',
|
||||
],
|
||||
'gh-auth' => [
|
||||
'pattern' => '/authentication failed|not logged in|requires authentication|bad credentials|401/i',
|
||||
'message' => 'authentication failed — run `gh auth login` and retry.',
|
||||
],
|
||||
'rate-limit' => [
|
||||
'pattern' => '/rate limit|too many requests|secondary rate limit/i',
|
||||
'message' => 'GitHub API rate limit hit — try again later.',
|
||||
],
|
||||
'not-found' => [
|
||||
'pattern' => '/404|not found|repository not found/i',
|
||||
'message' => 'workflow or artifact not found in repo.',
|
||||
],
|
||||
'forbidden' => [
|
||||
'pattern' => '/403|forbidden|access denied/i',
|
||||
'message' => 'access denied — check that your `gh` token has repo + actions read scope.',
|
||||
],
|
||||
/**
|
||||
* @var array<int, class-string<BaseRemote>>
|
||||
*/
|
||||
private const array REMOTES = [
|
||||
Baselines\GitHubRemote::class,
|
||||
Baselines\GitLabRemote::class,
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
@@ -60,11 +43,6 @@ final readonly class BaselineSync
|
||||
private WatchPatterns $watchPatterns,
|
||||
) {}
|
||||
|
||||
private function workflowFile(): string
|
||||
{
|
||||
return $this->watchPatterns->baselineWorkflow() ?? self::DEFAULT_WORKFLOW_FILE;
|
||||
}
|
||||
|
||||
private function renderBadge(string $type, string $content): void
|
||||
{
|
||||
View::render('components.badge', ['type' => $type, 'content' => $content]);
|
||||
@@ -77,12 +55,14 @@ final readonly class BaselineSync
|
||||
|
||||
public function fetchIfAvailable(string $projectRoot, bool $force = false, bool $hasAnchor = false): bool
|
||||
{
|
||||
$repo = $this->detectGitHubRepo($projectRoot);
|
||||
$detected = $this->detectRemote($projectRoot);
|
||||
|
||||
if ($repo === null) {
|
||||
if ($detected === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$remote, $repo] = $detected;
|
||||
|
||||
if (! $force && ($remaining = $this->cooldownRemaining()) !== null) {
|
||||
$this->renderBadge('WARN', sprintf(
|
||||
'Last fetch found no baseline — next auto-retry in %s. Override with --refetch.',
|
||||
@@ -92,7 +72,7 @@ final readonly class BaselineSync
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->download($repo, $projectRoot, $hasAnchor);
|
||||
$result = $this->download($remote, $repo, $projectRoot, $hasAnchor);
|
||||
$payload = $result['payload'];
|
||||
$failureKind = $result['failureKind'];
|
||||
|
||||
@@ -118,6 +98,23 @@ final readonly class BaselineSync
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: BaseRemote, 1: string}|null
|
||||
*/
|
||||
private function detectRemote(string $projectRoot): ?array
|
||||
{
|
||||
foreach (self::REMOTES as $class) {
|
||||
$remote = new $class($this->watchPatterns);
|
||||
$repo = $remote->detect($projectRoot);
|
||||
|
||||
if ($repo !== null) {
|
||||
return [$remote, $repo];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function cooldownRemaining(): ?int
|
||||
{
|
||||
$raw = $this->state->read(Tia::KEY_FETCH_COOLDOWN);
|
||||
@@ -164,7 +161,7 @@ final readonly class BaselineSync
|
||||
|
||||
private function emitPublishInstructions(): void
|
||||
{
|
||||
if ($this->isCi()) {
|
||||
if (Ci::isRunning()) {
|
||||
$this->renderBadge('INFO', 'No baseline yet — this run will produce one.');
|
||||
|
||||
return;
|
||||
@@ -174,59 +171,17 @@ final readonly class BaselineSync
|
||||
$this->renderChild('See https://pestphp.com/docs/tia for how to publish one from CI.');
|
||||
}
|
||||
|
||||
private function isCi(): bool
|
||||
{
|
||||
return getenv('GITHUB_ACTIONS') === 'true'
|
||||
|| getenv('GITLAB_CI') === 'true'
|
||||
|| getenv('CIRCLECI') === 'true';
|
||||
}
|
||||
|
||||
private function detectGitHubRepo(string $projectRoot): ?string
|
||||
{
|
||||
$gitConfig = $projectRoot.DIRECTORY_SEPARATOR.'.git'.DIRECTORY_SEPARATOR.'config';
|
||||
|
||||
if (! is_file($gitConfig)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = @file_get_contents($gitConfig);
|
||||
|
||||
if ($content === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/\[remote "origin"\][^\[]*?url\s*=\s*(\S+)/s', $content, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = $match[1];
|
||||
|
||||
if (preg_match('#^git@github\.com:([\w.-]+/[\w.-]+?)(?:\.git)?$#', $url, $m) === 1) {
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
if (preg_match('#^https?://github\.com/([\w.-]+/[\w.-]+?)(?:\.git)?/?$#', $url, $m) === 1) {
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
if (preg_match('#^ssh://(?:[^@/]+@)?github\.com(?::\d+)?/([\w.-]+/[\w.-]+?)(?:\.git)?/?$#i', $url, $m) === 1) {
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{payload: array{graph: string, coverage: ?string, sizeOnDisk: int}|null, failureKind: ?string}
|
||||
*/
|
||||
private function download(string $repo, string $projectRoot, bool $hasAnchor = false): array
|
||||
private function download(BaseRemote $remote, string $repo, string $projectRoot, bool $hasAnchor = false): array
|
||||
{
|
||||
$this->validateGhDependencies($hasAnchor);
|
||||
$this->validateCliDependencies($remote, $hasAnchor);
|
||||
|
||||
[$runId, $listError] = $this->latestSuccessfulRunIdWithError($repo);
|
||||
[$runId, $listError] = $remote->latestSuccessfulRunId($repo);
|
||||
|
||||
if ($listError !== null) {
|
||||
$this->panicOnClassifiedError($listError, 'Failed to query baseline runs', $hasAnchor);
|
||||
$this->panicOnClassifiedError($remote, $listError, 'Failed to query baseline runs', $hasAnchor);
|
||||
|
||||
$this->renderBadge('WARN', sprintf(
|
||||
'Failed to query baseline runs — %s',
|
||||
@@ -258,7 +213,7 @@ final readonly class BaselineSync
|
||||
return ['payload' => null, 'failureKind' => null];
|
||||
}
|
||||
|
||||
$download = $this->downloadArtifact($repo, $runId, $runCacheDir, $hasAnchor);
|
||||
$download = $this->downloadArtifact($remote, $repo, $runId, $runCacheDir, $hasAnchor);
|
||||
|
||||
if (! $download['success']) {
|
||||
return ['payload' => null, 'failureKind' => $download['failureKind']];
|
||||
@@ -274,7 +229,7 @@ final readonly class BaselineSync
|
||||
/**
|
||||
* @param array{kind: string, message: string} $diagnosis
|
||||
*/
|
||||
private function panicOnClassifiedError(array $diagnosis, string $contextPrefix, bool $hasAnchor): void
|
||||
private function panicOnClassifiedError(BaseRemote $remote, array $diagnosis, string $contextPrefix, bool $hasAnchor): void
|
||||
{
|
||||
if (! in_array($diagnosis['kind'], ['forbidden', 'not-found'], true)) {
|
||||
return;
|
||||
@@ -282,25 +237,25 @@ final readonly class BaselineSync
|
||||
|
||||
Panic::with(new BaselineFetchFailed(
|
||||
sprintf('%s — %s', $contextPrefix, $diagnosis['message']),
|
||||
sprintf('Verify workflow [%s], artifact [%s], and gh token scope.', $this->workflowFile(), self::ARTIFACT_NAME),
|
||||
sprintf('Verify your CI baseline configuration and `%s` token scope.', $remote->cliName()),
|
||||
$hasAnchor,
|
||||
));
|
||||
}
|
||||
|
||||
private function validateGhDependencies(bool $hasAnchor): void
|
||||
private function validateCliDependencies(BaseRemote $remote, bool $hasAnchor): void
|
||||
{
|
||||
if (! $this->commandExists('gh')) {
|
||||
if (! $remote->cliExists()) {
|
||||
Panic::with(new BaselineFetchFailed(
|
||||
'GitHub CLI (gh) not found — cannot fetch baseline.',
|
||||
'Install it from https://cli.github.com.',
|
||||
sprintf('%s CLI (%s) not found — cannot fetch baseline.', $remote->providerLabel(), $remote->cliName()),
|
||||
sprintf('Install it from %s.', $remote->installUrl()),
|
||||
$hasAnchor,
|
||||
));
|
||||
}
|
||||
|
||||
if (! $this->ghAuthenticated()) {
|
||||
if (! $remote->cliAuthenticated()) {
|
||||
Panic::with(new BaselineFetchFailed(
|
||||
'GitHub CLI (gh) is not authenticated — cannot fetch baseline.',
|
||||
'Run `gh auth login` and retry.',
|
||||
sprintf('%s CLI (%s) is not authenticated — cannot fetch baseline.', $remote->providerLabel(), $remote->cliName()),
|
||||
sprintf('Run `%s` and retry.', $remote->loginCommand()),
|
||||
$hasAnchor,
|
||||
));
|
||||
}
|
||||
@@ -309,9 +264,9 @@ final readonly class BaselineSync
|
||||
/**
|
||||
* @return array{success: bool, failureKind: ?string}
|
||||
*/
|
||||
private function downloadArtifact(string $repo, string $runId, string $runCacheDir, bool $hasAnchor): array
|
||||
private function downloadArtifact(BaseRemote $remote, string $repo, string $runId, string $runCacheDir, bool $hasAnchor): array
|
||||
{
|
||||
$artifactSize = $this->artifactSize($repo, $runId);
|
||||
$artifactSize = $remote->artifactSize($repo, $runId);
|
||||
|
||||
$this->output->writeln('');
|
||||
$this->renderChild($artifactSize !== null
|
||||
@@ -325,12 +280,7 @@ final readonly class BaselineSync
|
||||
$repo,
|
||||
));
|
||||
|
||||
$process = new Process([
|
||||
'gh', 'run', 'download', $runId,
|
||||
'-R', $repo,
|
||||
'-n', self::ARTIFACT_NAME,
|
||||
'-D', $runCacheDir,
|
||||
]);
|
||||
$process = new Process($remote->downloadCommand($repo, $runId, $runCacheDir));
|
||||
$process->setTimeout(900.0);
|
||||
$process->start();
|
||||
|
||||
@@ -351,9 +301,9 @@ final readonly class BaselineSync
|
||||
|
||||
$this->cleanup($runCacheDir);
|
||||
|
||||
$diagnosis = $this->classifyGhError($process->getErrorOutput().$process->getOutput());
|
||||
$diagnosis = $remote->classifyError($process->getErrorOutput().$process->getOutput());
|
||||
|
||||
$this->panicOnClassifiedError($diagnosis, 'Baseline download failed', $hasAnchor);
|
||||
$this->panicOnClassifiedError($remote, $diagnosis, 'Baseline download failed', $hasAnchor);
|
||||
|
||||
$this->renderBadge('WARN', sprintf(
|
||||
'Baseline download failed — %s',
|
||||
@@ -375,7 +325,7 @@ final readonly class BaselineSync
|
||||
|
||||
Panic::with(new BaselineFetchFailed(
|
||||
'Baseline downloaded but the artifact is missing expected files (graph.json).',
|
||||
'Your CI publish step is broken — check the workflow that uploads pest-tia-baseline.',
|
||||
'Your CI publish step is broken — check the job that uploads the TIA baseline artifact.',
|
||||
$hasAnchor,
|
||||
));
|
||||
}
|
||||
@@ -383,28 +333,6 @@ final readonly class BaselineSync
|
||||
return $payload;
|
||||
}
|
||||
|
||||
private function artifactSize(string $repo, string $runId): ?int
|
||||
{
|
||||
$process = new Process([
|
||||
'gh', 'api',
|
||||
sprintf('repos/%s/actions/runs/%s/artifacts', $repo, $runId),
|
||||
'--jq', sprintf(
|
||||
'.artifacts[] | select(.name == "%s") | .size_in_bytes', // @pest-ignore-type
|
||||
self::ARTIFACT_NAME,
|
||||
),
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$size = trim($process->getOutput());
|
||||
|
||||
return is_numeric($size) ? (int) $size : null;
|
||||
}
|
||||
|
||||
private function renderDownloadProgress(float $startedAt, int $tick): void
|
||||
{
|
||||
static $frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
@@ -526,69 +454,6 @@ final readonly class BaselineSync
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: ?string, 1: ?array{kind: string, message: string}}
|
||||
*/
|
||||
private function latestSuccessfulRunIdWithError(string $repo): array
|
||||
{
|
||||
$process = new Process([
|
||||
'gh', 'run', 'list',
|
||||
'-R', $repo,
|
||||
'--workflow', $this->workflowFile(),
|
||||
'--status', 'success',
|
||||
'--limit', '1',
|
||||
'--json', 'databaseId',
|
||||
'--jq', '.[0].databaseId // empty',
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return [null, $this->classifyGhError($process->getErrorOutput().$process->getOutput())];
|
||||
}
|
||||
|
||||
$runId = trim($process->getOutput());
|
||||
|
||||
return [$runId === '' ? null : $runId, null];
|
||||
}
|
||||
|
||||
private function ghAuthenticated(): bool
|
||||
{
|
||||
$process = new Process(['gh', 'auth', 'status']);
|
||||
$process->setTimeout(10.0);
|
||||
$process->run();
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{kind: string, message: string}
|
||||
*/
|
||||
private function classifyGhError(string $output): array
|
||||
{
|
||||
$output = trim($output);
|
||||
|
||||
if ($output === '') {
|
||||
return ['kind' => 'unknown', 'message' => 'unknown error'];
|
||||
}
|
||||
|
||||
foreach (self::DIAGNOSES as $kind => $diagnosis) {
|
||||
if (preg_match($diagnosis['pattern'], $output) === 1) {
|
||||
return ['kind' => $kind, 'message' => $diagnosis['message']];
|
||||
}
|
||||
}
|
||||
|
||||
return ['kind' => 'unknown', 'message' => trim(strtok($output, "\n"))];
|
||||
}
|
||||
|
||||
private function commandExists(string $cmd): bool
|
||||
{
|
||||
$process = new Process(['which', $cmd]);
|
||||
$process->run();
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
private function cleanup(string $dir): void
|
||||
{
|
||||
if (! is_dir($dir)) {
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins\Tia\Baselines;
|
||||
|
||||
use Pest\Plugins\Tia\WatchPatterns;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract readonly class BaseRemote // @pest-arch-ignore-line
|
||||
{
|
||||
public function __construct(protected WatchPatterns $watchPatterns) {}
|
||||
|
||||
abstract public function detect(string $projectRoot): ?string;
|
||||
|
||||
abstract public function cliName(): string;
|
||||
|
||||
abstract public function installUrl(): string;
|
||||
|
||||
abstract public function loginCommand(): string;
|
||||
|
||||
abstract public function providerLabel(): string;
|
||||
|
||||
/**
|
||||
* @return array{0: ?string, 1: ?array{kind: string, message: string}}
|
||||
*/
|
||||
abstract public function latestSuccessfulRunId(string $repo): array;
|
||||
|
||||
abstract public function artifactSize(string $repo, string $runId): ?int;
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
abstract public function downloadCommand(string $repo, string $runId, string $destDir): array;
|
||||
|
||||
public function cliExists(): bool
|
||||
{
|
||||
return new ExecutableFinder()->find($this->cliName()) !== null;
|
||||
}
|
||||
|
||||
public function cliAuthenticated(): bool
|
||||
{
|
||||
$process = new Process([$this->cliName(), 'auth', 'status']);
|
||||
$process->setTimeout(10.0);
|
||||
$process->run();
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{kind: string, message: string}
|
||||
*/
|
||||
public function classifyError(string $output): array
|
||||
{
|
||||
$output = trim($output);
|
||||
|
||||
if ($output === '') {
|
||||
return ['kind' => 'unknown', 'message' => 'unknown error'];
|
||||
}
|
||||
|
||||
foreach ($this->diagnoses() as $kind => $diagnosis) {
|
||||
if (preg_match($diagnosis['pattern'], $output) === 1) {
|
||||
return ['kind' => $kind, 'message' => $diagnosis['message']];
|
||||
}
|
||||
}
|
||||
|
||||
return ['kind' => 'unknown', 'message' => trim(strtok($output, "\n"))];
|
||||
}
|
||||
|
||||
protected function readOriginUrl(string $projectRoot): ?string // @pest-arch-ignore-line
|
||||
{
|
||||
$gitConfig = $projectRoot.DIRECTORY_SEPARATOR.'.git'.DIRECTORY_SEPARATOR.'config';
|
||||
|
||||
if (! is_file($gitConfig)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = @file_get_contents($gitConfig);
|
||||
|
||||
if ($content === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/\[remote "origin"\][^\[]*?url\s*=\s*(\S+)/s', $content, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $match[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: string, 1: string}|null
|
||||
*/
|
||||
protected function parseRemoteUrl(string $url): ?array // @pest-arch-ignore-line
|
||||
{
|
||||
if (preg_match('#^git@([^:]+):([\w./-]+?)(?:\.git)?$#', $url, $m) === 1) {
|
||||
return [$m[1], $m[2]];
|
||||
}
|
||||
|
||||
if (preg_match('#^https?://([^/]+)/([\w./-]+?)(?:\.git)?/?$#', $url, $m) === 1) {
|
||||
return [$m[1], $m[2]];
|
||||
}
|
||||
|
||||
if (preg_match('#^ssh://(?:[^@/]+@)?([^:/]+)(?::\d+)?/([\w./-]+?)(?:\.git)?/?$#i', $url, $m) === 1) {
|
||||
return [$m[1], $m[2]];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function resolveDefaultBranch(string $repo): string // @pest-arch-ignore-line
|
||||
{
|
||||
$configured = $this->watchPatterns->defaultBranch();
|
||||
|
||||
if ($configured !== null) {
|
||||
return $configured;
|
||||
}
|
||||
|
||||
$process = new Process(['git', 'symbolic-ref', 'refs/remotes/origin/HEAD']);
|
||||
$process->setTimeout(5.0);
|
||||
$process->run();
|
||||
|
||||
if ($process->isSuccessful()) {
|
||||
$ref = trim($process->getOutput());
|
||||
|
||||
$branch = str_replace('refs/remotes/origin/', '', $ref);
|
||||
|
||||
if ($branch !== '') {
|
||||
return $branch;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->remoteDefaultBranch($repo) ?? 'main';
|
||||
}
|
||||
|
||||
abstract protected function remoteDefaultBranch(string $repo): ?string; // @pest-arch-ignore-line
|
||||
|
||||
/**
|
||||
* @return array<string, array{pattern: string, message: string}>
|
||||
*/
|
||||
abstract protected function diagnoses(): array; // @pest-arch-ignore-line
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins\Tia\Baselines;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final readonly class GitHubRemote extends BaseRemote
|
||||
{
|
||||
private const string DEFAULT_WORKFLOW_FILE = 'tia-baseline.yml';
|
||||
|
||||
private const string ARTIFACT_NAME = 'pest-tia-baseline';
|
||||
|
||||
public function detect(string $projectRoot): ?string
|
||||
{
|
||||
$url = $this->readOriginUrl($projectRoot);
|
||||
|
||||
if ($url === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$parsed = $this->parseRemoteUrl($url);
|
||||
|
||||
if ($parsed === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$hostname, $path] = $parsed;
|
||||
|
||||
return strcasecmp($hostname, 'github.com') === 0 ? $path : null;
|
||||
}
|
||||
|
||||
public function cliName(): string
|
||||
{
|
||||
return 'gh';
|
||||
}
|
||||
|
||||
public function installUrl(): string
|
||||
{
|
||||
return 'https://cli.github.com';
|
||||
}
|
||||
|
||||
public function loginCommand(): string
|
||||
{
|
||||
return 'gh auth login';
|
||||
}
|
||||
|
||||
public function providerLabel(): string
|
||||
{
|
||||
return 'GitHub';
|
||||
}
|
||||
|
||||
public function latestSuccessfulRunId(string $repo): array
|
||||
{
|
||||
$process = new Process([
|
||||
'gh', 'run', 'list',
|
||||
'-R', $repo,
|
||||
'--workflow', $this->workflowFile(),
|
||||
'--status', 'success',
|
||||
'--limit', '1',
|
||||
'--json', 'databaseId',
|
||||
'--jq', '.[0].databaseId // empty',
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return [null, $this->classifyError($process->getErrorOutput().$process->getOutput())];
|
||||
}
|
||||
|
||||
$runId = trim($process->getOutput());
|
||||
|
||||
return [$runId === '' ? null : $runId, null];
|
||||
}
|
||||
|
||||
public function artifactSize(string $repo, string $runId): ?int
|
||||
{
|
||||
$process = new Process([
|
||||
'gh', 'api',
|
||||
sprintf('repos/%s/actions/runs/%s/artifacts', $repo, $runId),
|
||||
'--jq', sprintf(
|
||||
'.artifacts[] | select(.name === "%s") | .size_in_bytes',
|
||||
self::ARTIFACT_NAME,
|
||||
),
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$size = trim($process->getOutput());
|
||||
|
||||
return is_numeric($size) ? (int) $size : null;
|
||||
}
|
||||
|
||||
public function downloadCommand(string $repo, string $runId, string $destDir): array
|
||||
{
|
||||
return [
|
||||
'gh', 'run', 'download', $runId,
|
||||
'-R', $repo,
|
||||
'-n', self::ARTIFACT_NAME,
|
||||
'-D', $destDir,
|
||||
];
|
||||
}
|
||||
|
||||
protected function remoteDefaultBranch(string $repo): ?string // @pest-arch-ignore-line
|
||||
{
|
||||
$process = new Process([
|
||||
'gh', 'api',
|
||||
sprintf('repos/%s', $repo),
|
||||
'--jq', '.default_branch',
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$branch = trim($process->getOutput());
|
||||
|
||||
return $branch !== '' ? $branch : null;
|
||||
}
|
||||
|
||||
protected function diagnoses(): array // @pest-arch-ignore-line
|
||||
{
|
||||
return [
|
||||
'network' => [
|
||||
'pattern' => '/could not resolve host|connection refused|connection reset|temporary failure in name resolution|network is unreachable|no route to host|i\/o timeout|tls handshake|getaddrinfo/i',
|
||||
'message' => 'network error (offline or DNS unreachable). Try again when connected.',
|
||||
],
|
||||
'gh-auth' => [
|
||||
'pattern' => '/authentication failed|not logged in|requires authentication|bad credentials|401/i',
|
||||
'message' => 'authentication failed — run `gh auth login` and retry.',
|
||||
],
|
||||
'rate-limit' => [
|
||||
'pattern' => '/rate limit|too many requests|secondary rate limit/i',
|
||||
'message' => 'GitHub API rate limit hit — try again later.',
|
||||
],
|
||||
'not-found' => [
|
||||
'pattern' => '/404|not found|repository not found/i',
|
||||
'message' => 'workflow or artifact not found in repo.',
|
||||
],
|
||||
'forbidden' => [
|
||||
'pattern' => '/403|forbidden|access denied/i',
|
||||
'message' => 'access denied — check that your `gh` token has repo + actions read scope.',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function workflowFile(): string
|
||||
{
|
||||
return $this->watchPatterns->baselineWorkflow() ?? self::DEFAULT_WORKFLOW_FILE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins\Tia\Baselines;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final readonly class GitLabRemote extends BaseRemote
|
||||
{
|
||||
private const string DEFAULT_JOB_NAME = 'tia-baseline';
|
||||
|
||||
public function detect(string $projectRoot): ?string
|
||||
{
|
||||
$url = $this->readOriginUrl($projectRoot);
|
||||
|
||||
if ($url === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$parsed = $this->parseRemoteUrl($url);
|
||||
|
||||
if ($parsed === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$hostname, $path] = $parsed;
|
||||
|
||||
if (strcasecmp($hostname, 'github.com') === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (strcasecmp($hostname, 'gitlab.com') === 0) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if (! $this->cliExists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function cliName(): string
|
||||
{
|
||||
return 'glab';
|
||||
}
|
||||
|
||||
public function installUrl(): string
|
||||
{
|
||||
return 'https://gitlab.com/gitlab-org/cli#installation';
|
||||
}
|
||||
|
||||
public function loginCommand(): string
|
||||
{
|
||||
return 'glab auth login';
|
||||
}
|
||||
|
||||
public function providerLabel(): string
|
||||
{
|
||||
return 'GitLab';
|
||||
}
|
||||
|
||||
public function latestSuccessfulRunId(string $repo): array
|
||||
{
|
||||
$encodedRepo = rawurlencode($repo);
|
||||
$jobName = $this->jobName();
|
||||
$defaultBranch = $this->resolveDefaultBranch($repo);
|
||||
|
||||
$process = new Process([
|
||||
'glab', 'api',
|
||||
sprintf('projects/%s/jobs?scope[]=success&per_page=100', $encodedRepo),
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return [null, $this->classifyError($process->getErrorOutput().$process->getOutput())];
|
||||
}
|
||||
|
||||
$runId = $this->findPipelineId($process->getOutput(), $jobName, $defaultBranch);
|
||||
|
||||
return [$runId, null];
|
||||
}
|
||||
|
||||
public function artifactSize(string $repo, string $runId): ?int
|
||||
{
|
||||
$encodedRepo = rawurlencode($repo);
|
||||
$jobName = $this->jobName();
|
||||
|
||||
$process = new Process([
|
||||
'glab', 'api',
|
||||
sprintf('projects/%s/pipelines/%s/jobs', $encodedRepo, $runId),
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->findArtifactSize($process->getOutput(), $jobName);
|
||||
}
|
||||
|
||||
public function downloadCommand(string $repo, string $runId, string $destDir): array
|
||||
{
|
||||
return [
|
||||
'glab', 'job', 'artifact',
|
||||
$this->resolveDefaultBranch($repo),
|
||||
$this->jobName(),
|
||||
'-R', $repo,
|
||||
'--path', $destDir,
|
||||
];
|
||||
}
|
||||
|
||||
protected function remoteDefaultBranch(string $repo): ?string // @pest-arch-ignore-line
|
||||
{
|
||||
$process = new Process([
|
||||
'glab', 'api',
|
||||
sprintf('projects/%s', rawurlencode($repo)),
|
||||
]);
|
||||
$process->setTimeout(30.0);
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$project = json_decode($process->getOutput(), true);
|
||||
$branch = is_array($project) ? ($project['default_branch'] ?? null) : null;
|
||||
|
||||
return is_string($branch) && $branch !== '' ? $branch : null;
|
||||
}
|
||||
|
||||
protected function diagnoses(): array // @pest-arch-ignore-line
|
||||
{
|
||||
return [
|
||||
'network' => [
|
||||
'pattern' => '/could not resolve host|connection refused|connection reset|temporary failure|network is unreachable|no route to host|tls handshake|dial tcp/i',
|
||||
'message' => 'network error (offline or DNS unreachable). Try again when connected.',
|
||||
],
|
||||
'glab-auth' => [
|
||||
'pattern' => '/authentication failed|not logged in|requires authentication|unauthorized|401|token expired|invalid token/i',
|
||||
'message' => 'authentication failed — run `glab auth login` and retry.',
|
||||
],
|
||||
'rate-limit' => [
|
||||
'pattern' => '/rate limit|too many requests|429/i',
|
||||
'message' => 'GitLab API rate limit hit — try again later.',
|
||||
],
|
||||
'not-found' => [
|
||||
'pattern' => '/404|not found|project not found|does not exist/i',
|
||||
'message' => 'pipeline, job, or artifact not found in project.',
|
||||
],
|
||||
'forbidden' => [
|
||||
'pattern' => '/403|forbidden|access denied|insufficient scope/i',
|
||||
'message' => 'access denied — check that your `glab` token has read_api scope.',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function jobName(): string
|
||||
{
|
||||
return $this->watchPatterns->baselineJob() ?? self::DEFAULT_JOB_NAME;
|
||||
}
|
||||
|
||||
private function findPipelineId(string $output, string $jobName, string $defaultBranch): ?string
|
||||
{
|
||||
$jobs = json_decode($output, true);
|
||||
|
||||
if (! is_array($jobs)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($jobs as $job) {
|
||||
if (! is_array($job)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($job['name'] ?? null) !== $jobName || ($job['ref'] ?? null) !== $defaultBranch) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $job['pipeline']['id'] ?? null;
|
||||
|
||||
return is_int($id) || is_string($id) ? (string) $id : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function findArtifactSize(string $output, string $jobName): ?int
|
||||
{
|
||||
$jobs = json_decode($output, true);
|
||||
|
||||
if (! is_array($jobs)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($jobs as $job) {
|
||||
if (! is_array($job) || ($job['name'] ?? null) !== $jobName || ! is_array($job['artifacts'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$size = 0;
|
||||
|
||||
foreach ($job['artifacts'] as $artifact) {
|
||||
if (is_array($artifact) && is_int($artifact['size'] ?? null)) {
|
||||
$size += $artifact['size'];
|
||||
}
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,23 @@ final readonly class ChangedFiles
|
||||
|
||||
private function shaIsReachable(string $sha): bool
|
||||
{
|
||||
return $this->git->succeeds(['merge-base', '--is-ancestor', $sha, 'HEAD']);
|
||||
if ($this->git->succeeds(['merge-base', '--is-ancestor', $sha, 'HEAD'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$parents = $this->git->raw(['show', '--no-patch', '--format=%P', $sha]);
|
||||
|
||||
if ($parents === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parents = explode(' ', trim($parents));
|
||||
|
||||
if (count($parents) < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_all($parents, fn (string $parent): bool => $this->git->succeeds(['merge-base', '--is-ancestor', $parent, 'HEAD']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ use Pest\Plugins\Tia\Contracts\Ci;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class CiDefaultBranch
|
||||
final class CiBranch
|
||||
{
|
||||
/**
|
||||
* @var array<int, class-string<Ci>>
|
||||
@@ -19,7 +19,20 @@ final class CiDefaultBranch
|
||||
Cis\GitHub::class,
|
||||
];
|
||||
|
||||
public static function detect(): ?string
|
||||
public static function detectCurrent(): ?string
|
||||
{
|
||||
foreach (self::CIS as $class) {
|
||||
$branch = (new $class)->currentBranch();
|
||||
|
||||
if ($branch !== null) {
|
||||
return $branch;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function detectDefault(): ?string
|
||||
{
|
||||
foreach (self::CIS as $class) {
|
||||
$branch = (new $class)->defaultBranch();
|
||||
@@ -14,6 +14,11 @@ final readonly class GitHub implements Ci
|
||||
{
|
||||
use ReadsEnvironment;
|
||||
|
||||
public function currentBranch(): ?string
|
||||
{
|
||||
return $this->environment('GITHUB_REF_NAME');
|
||||
}
|
||||
|
||||
public function defaultBranch(): ?string
|
||||
{
|
||||
$path = $this->environment('GITHUB_EVENT_PATH');
|
||||
|
||||
@@ -14,6 +14,11 @@ final readonly class GitLab implements Ci
|
||||
{
|
||||
use ReadsEnvironment;
|
||||
|
||||
public function currentBranch(): ?string
|
||||
{
|
||||
return $this->environment('CI_COMMIT_BRANCH');
|
||||
}
|
||||
|
||||
public function defaultBranch(): ?string
|
||||
{
|
||||
return $this->environment('CI_DEFAULT_BRANCH');
|
||||
|
||||
@@ -61,7 +61,7 @@ final class Configuration
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function baselined(?string $workflow = null): self
|
||||
public function baselined(?string $workflow = null, ?string $job = null): self
|
||||
{
|
||||
/** @var WatchPatterns $watchPatterns */
|
||||
$watchPatterns = Container::getInstance()->get(WatchPatterns::class);
|
||||
@@ -71,6 +71,10 @@ final class Configuration
|
||||
$watchPatterns->setBaselineWorkflow($workflow);
|
||||
}
|
||||
|
||||
if ($job !== null) {
|
||||
$watchPatterns->setBaselineJob($job);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,7 @@ namespace Pest\Plugins\Tia\Contracts;
|
||||
*/
|
||||
interface Ci
|
||||
{
|
||||
public function currentBranch(): ?string;
|
||||
|
||||
public function defaultBranch(): ?string;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,9 @@ use Pest\Plugins\Tia\Contracts\State;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class FileState implements State
|
||||
final readonly class FileState implements State
|
||||
{
|
||||
private readonly string $rootDir;
|
||||
|
||||
private ?string $resolvedRoot = null;
|
||||
private string $rootDir;
|
||||
|
||||
public function __construct(string $rootDir)
|
||||
{
|
||||
@@ -106,17 +104,9 @@ final class FileState implements State
|
||||
|
||||
private function resolvedRoot(): ?string
|
||||
{
|
||||
if ($this->resolvedRoot !== null) {
|
||||
return $this->resolvedRoot;
|
||||
}
|
||||
|
||||
$resolved = @realpath($this->rootDir);
|
||||
|
||||
if ($resolved === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->resolvedRoot = $resolved;
|
||||
return $resolved === false ? null : $resolved;
|
||||
}
|
||||
|
||||
private function ensureRoot(): bool
|
||||
|
||||
@@ -18,6 +18,8 @@ use PHPUnit\TextUI\Configuration\Registry;
|
||||
*/
|
||||
final class Graph
|
||||
{
|
||||
public const string WORKSPACE_BRANCH_PREFIX = '@workspace:';
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
@@ -1628,6 +1630,10 @@ final class Graph
|
||||
$survivors = array_fill_keys($keep, true);
|
||||
|
||||
foreach (array_keys($this->baselines) as $branch) {
|
||||
if (str_starts_with($branch, self::WORKSPACE_BRANCH_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($survivors[$branch])) {
|
||||
unset($this->baselines[$branch]);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ final class Recorder
|
||||
$lineKeys = array_keys($lines);
|
||||
$reportsUnexecutedLines = count($covered) < count($lines);
|
||||
|
||||
if ($reportsUnexecutedLines && $lineKeys !== [] && count($covered) === 1 && $covered[0] === max($lineKeys)) {
|
||||
if ($reportsUnexecutedLines && count($covered) === 1 && $covered[0] === max($lineKeys)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ final class WatchPatterns
|
||||
|
||||
private ?string $baselineWorkflow = null;
|
||||
|
||||
private ?string $baselineJob = null;
|
||||
|
||||
public function useDefaults(string $projectRoot): void
|
||||
{
|
||||
$testPath = TestSuite::getInstance()->testPath;
|
||||
@@ -203,6 +205,18 @@ final class WatchPatterns
|
||||
return $this->baselineWorkflow;
|
||||
}
|
||||
|
||||
public function setBaselineJob(string $job): void
|
||||
{
|
||||
$job = trim($job);
|
||||
|
||||
$this->baselineJob = $job === '' ? null : $job;
|
||||
}
|
||||
|
||||
public function baselineJob(): ?string
|
||||
{
|
||||
return $this->baselineJob;
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
$this->patterns = [];
|
||||
@@ -213,6 +227,7 @@ final class WatchPatterns
|
||||
$this->baselined = false;
|
||||
$this->defaultBranch = null;
|
||||
$this->baselineWorkflow = null;
|
||||
$this->baselineJob = null;
|
||||
}
|
||||
|
||||
private function keyMatches(string $key, string $file): bool
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Support;
|
||||
|
||||
use Pest\Plugins\Environment;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Ci
|
||||
{
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private const array ENVIRONMENT_VARIABLES = [
|
||||
'CI',
|
||||
'GITHUB_ACTIONS',
|
||||
'GITLAB_CI',
|
||||
'CIRCLECI',
|
||||
'TRAVIS',
|
||||
'APPVEYOR',
|
||||
'BITBUCKET_BUILD_NUMBER',
|
||||
'BUILDKITE',
|
||||
'TEAMCITY_VERSION',
|
||||
'JENKINS_URL',
|
||||
'SYSTEM_COLLECTIONURI',
|
||||
'CI_NAME',
|
||||
'TASKCLUSTER_ROOT_URL',
|
||||
'DRONE',
|
||||
'WERCKER',
|
||||
'NEVERCODE',
|
||||
'SEMAPHORE',
|
||||
'NETLIFY',
|
||||
'NOW_BUILDER',
|
||||
];
|
||||
|
||||
public static function isRunning(): bool
|
||||
{
|
||||
if (Environment::name() === Environment::CI) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return array_any(self::ENVIRONMENT_VARIABLES, fn (string $env): bool => getenv($env) !== false);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Pest Testing Framework 5.1.4.
|
||||
Pest Testing Framework 5.3.1.
|
||||
|
||||
USAGE: pest <file> [options]
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
--testsuite [name] ......... Only run tests from the specified test suite(s)
|
||||
--exclude-testsuite [name] .. Exclude tests from the specified test suite(s)
|
||||
--list-groups ................................... List available test groups
|
||||
--group [name] .................. Only run tests from the specified group(s)
|
||||
--exclude-group [name] ........... Exclude tests from the specified group(s)
|
||||
--group [name] Only run tests from the specified group(s); use "a+b" for the tests that are in group "a" and in group "b"
|
||||
--exclude-group [name] Exclude tests from the specified group(s); use "a+b" for the tests that are in group "a" and in group "b"
|
||||
--covers [name] ................. Only run tests that intend to cover [name]
|
||||
--uses [name] ..................... Only run tests that intend to use [name]
|
||||
--requires-php-extension [name] Only run tests that require PHP extension [name]
|
||||
@@ -63,6 +63,7 @@
|
||||
--disallow-test-output ................. Be strict about output during tests
|
||||
--enforce-time-limit ................. Enforce time limit based on test size
|
||||
--default-time-limit [sec] Timeout in seconds for tests that have no declared size
|
||||
--timeout [sec] Stop the test run after the specified number of seconds (wall-clock time for the entire run)
|
||||
--do-not-report-useless-tests Do not report tests that do not test anything
|
||||
--stop-on-defect[=[n]] Stop after first (or n-th) error, failure, warning, or risky test
|
||||
--stop-on-error[=[n]] ..................... Stop after first (or n-th) error
|
||||
@@ -102,11 +103,13 @@
|
||||
--do-not-fail-on-incomplete Do not signal failure using shell exit code when a test was marked incomplete
|
||||
--record-test-run-history .......................... Record test run history
|
||||
--do-not-record-test-run-history ............ Do not record test run history
|
||||
--cache-test-index .......................... Write test index to cache file
|
||||
--do-not-cache-test-index ............ Do not write test index to cache file
|
||||
--warn-when-php-is-not-configured-for-development Trigger a test runner warning when PHP is not configured for development
|
||||
--do-not-warn-when-php-is-not-configured-for-development Do not trigger a test runner warning when PHP is not configured for development
|
||||
--order-by [order] Run tests in order: default|defects|depends|duration-ascending|duration-descending|no-depends|random|reverse|size-ascending|size-descending
|
||||
--resolve-dependencies ...................... Alias for "--order-by depends"
|
||||
--ignore-dependencies .................... Alias for "--order-by no-depends"
|
||||
--order-by [order] Run tests in order: default|defects|duration-ascending|duration-descending|modified-ascending|modified-descending|random|reverse|size-ascending|size-descending
|
||||
--resolve-dependencies Reorder tests to resolve dependencies between them (default)
|
||||
--ignore-dependencies Do not reorder tests to resolve dependencies between them
|
||||
--random-order ............................... Alias for "--order-by random"
|
||||
--random-order-seed [N] Use the specified random seed when running tests in random order
|
||||
--repeat [N] .......... Run each test N times, stopping at the first failure
|
||||
@@ -163,6 +166,7 @@
|
||||
--coverage-html [dir] Write code coverage report in HTML format to directory
|
||||
--without-class-view Render code coverage report in HTML format without class view
|
||||
--without-file-view Render code coverage report in HTML format without file view
|
||||
--coverage-jsonl [dir] Write code coverage report in JSONL format to directory
|
||||
--coverage-php [file] .......... Write serialized code coverage data to file
|
||||
--coverage-text=[file] Write code coverage report in text format to file [default: standard output]
|
||||
--only-summary-for-coverage-text Option for code coverage report in text format: only show summary
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
Pest Testing Framework 5.1.4.
|
||||
Pest Testing Framework 5.3.1.
|
||||
|
||||
|
||||
@@ -275,6 +275,7 @@
|
||||
✓ dataset items can mix named and sequential styles with ('Taylor', 'taylor@laravel.com')
|
||||
✓ dataset items can mix named and sequential styles with ('James', 'james@laravel.com') #1
|
||||
✓ dataset items can mix named and sequential styles with ('James', 'james@laravel.com') #2
|
||||
✓ named parameters work with a single argument with ('Taylor')
|
||||
|
||||
PASS Tests\Features\Depends
|
||||
✓ first
|
||||
@@ -2209,6 +2210,9 @@
|
||||
PASS Tests\Visual\Collision
|
||||
✓ collision with ([''])
|
||||
|
||||
PASS Tests\Visual\FailingBoot
|
||||
✓ a failure in the boot files renders only that failure
|
||||
|
||||
PASS Tests\Visual\Help
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
@@ -2255,4 +2259,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, 1598 passed (3485 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1600 passed (3489 assertions)
|
||||
@@ -494,3 +494,9 @@ test('dataset items can mix named and sequential styles', function (string $name
|
||||
['James', 'james@laravel.com'],
|
||||
['James', 'email' => 'james@laravel.com'],
|
||||
]);
|
||||
|
||||
test('named parameters work with a single argument', function (string $name): void {
|
||||
expect($name)->toBe('Taylor');
|
||||
})->with([
|
||||
['name' => 'Taylor'],
|
||||
]);
|
||||
|
||||
@@ -115,7 +115,7 @@ test('a narrowed run does not reclaim anything', function (): void {
|
||||
->and($delta->isResultsOnly())->toBeTrue($delta->summary());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a detached HEAD does not reclaim anything either', function (): void {
|
||||
test('a detached HEAD reclaims missing branches without changing the default baseline', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -130,8 +130,11 @@ test('a detached HEAD does not reclaim anything either', function (): void {
|
||||
$project->pest('--tia');
|
||||
$delta = $project->delta();
|
||||
|
||||
expect($project->branchKeys())->toBe(['master', 'feature-x'])
|
||||
->and($delta->isHardSuppressed())->toBeTrue($delta->summary());
|
||||
expect($project->branchKeys())->toHaveCount(2)
|
||||
->and($project->branchKeys())->toContain('master')
|
||||
->and($project->branchKeys())->not->toContain('feature-x')
|
||||
->and($delta->baselineUntouched('master'))->toBeTrue($delta->summary())
|
||||
->and($delta->structureMoved())->toBeTrue($delta->summary());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('the default branch baseline survives every branch that comes and goes', function (): void {
|
||||
|
||||
@@ -104,17 +104,20 @@ test('filtered mode finds nothing to do on the default branch itself', function
|
||||
->and($delta->isHardSuppressed())->toBeTrue($delta->summary());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a detached HEAD replays without minting a branch key', function (): void {
|
||||
test('a detached HEAD replays through a workspace baseline', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
$project->git()->detach();
|
||||
|
||||
$result = $project->pest('--tia');
|
||||
$hasWorkspaceBranch = array_any($project->branchKeys(), fn (string $branch): bool => str_starts_with($branch, '@workspace:'));
|
||||
|
||||
expect($result->replayed())->toBe(Project::TOTAL_TESTS, $result->describe())
|
||||
->and($result->uncached())->toBe(0, $result->describe())
|
||||
->and($project->branchKeys())->toBe(['master']);
|
||||
->and($project->branchKeys())->toHaveCount(2)
|
||||
->and($project->branchKeys())->toContain('master')
|
||||
->and($hasWorkspaceBranch)->toBeTrue();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a detached HEAD does not write into the default branch baseline', function (array $arguments): void {
|
||||
@@ -125,9 +128,13 @@ test('a detached HEAD does not write into the default branch baseline', function
|
||||
$project->pest(...$arguments);
|
||||
|
||||
$delta = $project->delta();
|
||||
$hasWorkspaceBranch = array_any($project->branchKeys(), fn (string $branch): bool => str_starts_with($branch, '@workspace:'));
|
||||
|
||||
expect($delta->baselineUntouched('master'))->toBeTrue($delta->summary())
|
||||
->and($project->branchKeys())->toBe(['master']);
|
||||
->and($project->branchKeys())->toHaveCount(2)
|
||||
->and($project->branchKeys())->toContain('master')
|
||||
->and($hasWorkspaceBranch)->toBeTrue()
|
||||
->and($delta->writtenCount())->toBe(0, $delta->summary());
|
||||
})->with([
|
||||
'sequential' => [['--filter=adds two numbers']],
|
||||
'parallel' => [['--parallel', '--processes=2', '--filter=adds two numbers']],
|
||||
@@ -147,6 +154,26 @@ test('the branch that ran gets its own key and the default branch keeps its base
|
||||
->and($delta->writtenCount())->toBe(0, $delta->summary());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a detached CI branch writes into its branch baseline', function (array $environment): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
$project->git()->detach();
|
||||
$project->pestWithEnvironment($project->path(), $environment, '--filter=adds two numbers');
|
||||
|
||||
expect($project->branchKeys())->toBe(['master', 'feature-x'])
|
||||
->and(array_any($project->branchKeys(), fn (string $branch): bool => str_starts_with($branch, '@workspace:')))->toBeFalse();
|
||||
})->with([
|
||||
'GitLab' => [[
|
||||
'GITLAB_CI' => 'true',
|
||||
'CI_COMMIT_BRANCH' => 'feature-x',
|
||||
]],
|
||||
'GitHub' => [[
|
||||
'GITHUB_ACTIONS' => 'true',
|
||||
'GITHUB_REF_NAME' => 'feature-x',
|
||||
]],
|
||||
])->skipOnWindows();
|
||||
|
||||
test('the fallback reaches parallel workers', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Pest\Plugins\Tia\ChangedFiles;
|
||||
use Tests\Fixtures\Tia\Project;
|
||||
|
||||
afterEach(function (): void {
|
||||
Project::destroyAll();
|
||||
});
|
||||
|
||||
test('a replacement CI merge reuses its baseline and selects changed tests on either parent', function (array $arguments, string $changedBranch): void {
|
||||
$project = Project::make('master');
|
||||
$git = $project->git();
|
||||
$git->switchTo('feature', new: true);
|
||||
$git->commit('feature');
|
||||
$git->run(['checkout', '--detach', 'master']);
|
||||
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
|
||||
$project->seed('123/merge');
|
||||
|
||||
$git->switchTo($changedBranch);
|
||||
$project->write('tests/Unit/CalculatorTest.php', str_replace(
|
||||
'->add(1, 2)',
|
||||
'->add(2, 1)',
|
||||
file_get_contents($project->path('tests/Unit/CalculatorTest.php')) ?: throw new RuntimeException('Missing calculator test fixture.'),
|
||||
));
|
||||
$git->commit('change calculator');
|
||||
$git->run(['checkout', '--detach', 'master']);
|
||||
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), [
|
||||
'GITHUB_REF_NAME' => '123/merge',
|
||||
], '--tia', ...$arguments);
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->output)->not->toContain('no longer reachable')
|
||||
->and($result->replayed())->toBe(4, $result->describe())
|
||||
->and($result->tally())->toContain('6 passed');
|
||||
})->with(Project::SEQUENTIAL_AND_PARALLEL)->with(['feature', 'master'])->skipOnWindows();
|
||||
|
||||
test('a merge baseline is rejected when one of its parents is absent from the current history', function (): void {
|
||||
$project = Project::make('master');
|
||||
$git = $project->git();
|
||||
$git->switchTo('feature', new: true);
|
||||
$git->commit('feature');
|
||||
$git->run(['checkout', '--detach', 'master']);
|
||||
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
|
||||
$sha = $git->sha();
|
||||
$git->switchTo('master');
|
||||
|
||||
expect(new ChangedFiles($project->path())->since($sha))->toBeNull();
|
||||
})->skipOnWindows();
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Tests\Fixtures\Tia\Project;
|
||||
|
||||
afterEach(function (): void {
|
||||
Project::destroyAll();
|
||||
});
|
||||
|
||||
/**
|
||||
* @param callable(array<string, mixed>): array<string, mixed>|null $mutator
|
||||
* @return array{0: Project, 1: array<string, string>}
|
||||
*/
|
||||
function tiaPublishedBaselineGitLab(string $mode = 'ok', ?callable $mutator = null): array
|
||||
{
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
$payload = $project->detachGraph();
|
||||
|
||||
if ($mutator !== null) {
|
||||
/** @var array<string, mixed> $decoded */
|
||||
$decoded = json_decode($payload, true);
|
||||
$payload = (string) json_encode($mutator($decoded), JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
return [$project, $project->glab($mode, $payload)];
|
||||
}
|
||||
|
||||
test('a self-hosted GitLab baseline is fetched when glab is available', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
$payload = $project->detachGraph();
|
||||
|
||||
$environment = $project->glab('ok', $payload, 'gitlab.acme.com');
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->output)->toContain('Downloading TIA baseline')
|
||||
->and($result->replayed())->toBe(Project::TOTAL_TESTS, $result->describe())
|
||||
->and($project->graphExists())->toBeTrue();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a published GitLab baseline is fetched instead of recorded locally', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab();
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->output)->toContain('Downloading TIA baseline')
|
||||
->and($result->replayed())->toBe(Project::TOTAL_TESTS, $result->describe())
|
||||
->and($project->graphExists())->toBeTrue();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a fetched GitLab baseline that will not decode is discarded rather than trusted', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('corrupt');
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->output)->toContain('The dependency graph could not be read')
|
||||
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed')
|
||||
->and($result->replayed())->toBe(0, $result->describe());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a fetched GitLab baseline recorded against another tree is not used', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('ok', function (array $graph): array {
|
||||
$graph['fingerprint']['structural']['composer_lock'] = 'a-lockfile-this-project-never-had';
|
||||
|
||||
return $graph;
|
||||
});
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed')
|
||||
->and($result->replayed())->toBe(0, $result->describe());
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a GitLab artifact without a graph in it fails loudly', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('missing-asset');
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(1, $result->describe())
|
||||
->and($result->output)->toContain('the artifact is missing expected files')
|
||||
->and($project->graphExists())->toBeFalse();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a GitLab baseline that cannot be authenticated for fails loudly', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('unauthenticated');
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(1, $result->describe())
|
||||
->and($result->output)->toContain('is not authenticated')
|
||||
->and($project->graphExists())->toBeFalse();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a GitLab pipeline or job that is not there fails loudly', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('list-404');
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(1, $result->describe())
|
||||
->and($result->output)->toContain('not found in project')
|
||||
->and($project->graphExists())->toBeFalse();
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a GitLab network failure warns and lets the suite run', function (string $mode): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab($mode);
|
||||
|
||||
$result = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->output)->toContain('network error')
|
||||
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed');
|
||||
})->with([
|
||||
'querying the runs' => ['list-network'],
|
||||
'downloading the artifact' => ['download-network'],
|
||||
])->skipOnWindows();
|
||||
|
||||
test('no published GitLab baseline yet starts a cooldown', function (): void {
|
||||
[$project, $environment] = tiaPublishedBaselineGitLab('no-runs');
|
||||
|
||||
$discardGraph = function () use ($project): void {
|
||||
if ($project->graphExists()) {
|
||||
$project->detachGraph();
|
||||
}
|
||||
};
|
||||
|
||||
$first = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($first->exitCode)->toBe(0, $first->describe())
|
||||
->and($first->output)->toContain('No baseline published yet')
|
||||
->and($project->graphDir().DIRECTORY_SEPARATOR.'fetch-cooldown.json')->toBeFile();
|
||||
|
||||
$discardGraph();
|
||||
|
||||
$second = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($second->exitCode)->toBe(0, $second->describe())
|
||||
->and($second->output)->toContain('next auto-retry in');
|
||||
|
||||
file_put_contents($project->graphDir().DIRECTORY_SEPARATOR.'fetch-cooldown.json', 'not json{');
|
||||
|
||||
$discardGraph();
|
||||
|
||||
$third = $project->pestWithEnvironment($project->path(), $environment, '--tia', '--baselined');
|
||||
|
||||
expect($third->exitCode)->toBe(0, $third->describe())
|
||||
->and($third->output)->toContain('No baseline published yet')
|
||||
->and($third->tally())->toContain(Project::TOTAL_TESTS.' passed');
|
||||
})->skipOnWindows();
|
||||
@@ -8,7 +8,7 @@ afterEach(function (): void {
|
||||
Project::destroyAll();
|
||||
});
|
||||
|
||||
test('a detached HEAD does not purge the graph on structural drift', function (array $arguments): void {
|
||||
test('a detached HEAD can rebuild the graph on structural drift', function (array $arguments): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -25,10 +25,10 @@ test('a detached HEAD does not purge the graph on structural drift', function (a
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($project->graphExists())->toBeTrue('the detached run deleted graph.json')
|
||||
->and($delta->isHardSuppressed())->toBeTrue($delta->summary());
|
||||
->and($delta->structureMoved())->toBeTrue($delta->summary());
|
||||
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
||||
|
||||
test('a detached HEAD does not purge the graph with --fresh either', function (array $arguments): void {
|
||||
test('a detached HEAD can rebuild the graph with --fresh', function (array $arguments): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -39,10 +39,10 @@ test('a detached HEAD does not purge the graph with --fresh either', function (a
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($project->graphExists())->toBeTrue('the detached --fresh run deleted graph.json')
|
||||
->and($delta->isHardSuppressed())->toBeTrue($delta->summary());
|
||||
->and($delta->structureMoved())->toBeTrue($delta->summary());
|
||||
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
||||
|
||||
test('a detached HEAD leaves an unreadable graph for a checkout that can rebuild it', function (): void {
|
||||
test('a detached HEAD can replace an unreadable graph for a checkout that can rebuild it', function (): void {
|
||||
$project = Project::make('master');
|
||||
$project->seed('master');
|
||||
|
||||
@@ -54,7 +54,7 @@ test('a detached HEAD leaves an unreadable graph for a checkout that can rebuild
|
||||
|
||||
expect($result->exitCode)->toBe(0, $result->describe())
|
||||
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed')
|
||||
->and(file_get_contents($project->graphDir().'/graph.json'))->toBe('{not json');
|
||||
->and(file_get_contents($project->graphDir().'/graph.json'))->not->toBe('{not json');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('a cached failure whose test file was deleted stops widening later runs', function (array $arguments): void {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
throw new RuntimeException('The boot of the test suite failed.');
|
||||
@@ -65,6 +65,11 @@ final readonly class GitRepo
|
||||
$this->run(['remote', 'remove', 'origin']);
|
||||
}
|
||||
|
||||
public function setOriginUrl(string $url): void
|
||||
{
|
||||
$this->run(['remote', 'set-url', 'origin', $url]);
|
||||
}
|
||||
|
||||
public function setOriginHead(string $branch): void
|
||||
{
|
||||
$this->run(['update-ref', 'refs/remotes/origin/'.$branch, 'HEAD']);
|
||||
|
||||
@@ -157,7 +157,7 @@ final class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $environment
|
||||
* @param array<string, string|false> $environment
|
||||
*/
|
||||
public function pestWithEnvironment(string $directory, array $environment, string ...$arguments): PestResult
|
||||
{
|
||||
@@ -172,11 +172,14 @@ final class Project
|
||||
'PAO_DISABLE' => '1',
|
||||
'XDEBUG_MODE' => 'coverage',
|
||||
'HOME' => $this->home(),
|
||||
'GITHUB_EVENT_PATH' => '',
|
||||
'CI_DEFAULT_BRANCH' => '',
|
||||
'GITHUB_ACTIONS' => '',
|
||||
'GITLAB_CI' => '',
|
||||
'CIRCLECI' => '',
|
||||
'CI' => false,
|
||||
'GITHUB_EVENT_PATH' => false,
|
||||
'CI_DEFAULT_BRANCH' => false,
|
||||
'CI_COMMIT_BRANCH' => false,
|
||||
'GITHUB_ACTIONS' => false,
|
||||
'GITHUB_REF_NAME' => false,
|
||||
'GITLAB_CI' => false,
|
||||
'CIRCLECI' => false,
|
||||
...$environment,
|
||||
],
|
||||
);
|
||||
@@ -288,6 +291,25 @@ final class Project
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function glab(string $mode = 'ok', string $payload = '{}', string $host = 'gitlab.com'): array
|
||||
{
|
||||
$this->git()->setOriginUrl(sprintf('git@%s:pestphp/tia-fixture.git', $host));
|
||||
|
||||
self::mirror(__DIR__.'/stubs/glab', $this->path('stub/glab'));
|
||||
chmod($this->path('stub/glab'), 0755);
|
||||
|
||||
$this->write('payload/graph.json', $payload);
|
||||
|
||||
return [
|
||||
'PATH' => $this->path('stub').PATH_SEPARATOR.getenv('PATH'),
|
||||
'GLAB_STUB_MODE' => $mode,
|
||||
'GLAB_STUB_PAYLOAD' => $this->path('payload/graph.json'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function testId(string $testFile, string $description): string
|
||||
{
|
||||
$basename = basename($testFile, '.php');
|
||||
@@ -497,13 +519,21 @@ final class Project
|
||||
throw new RuntimeException(sprintf('Unable to create [%s].', $directory));
|
||||
}
|
||||
|
||||
if (@link($from, $to) || @copy($from, $to)) {
|
||||
if ((self::shareDevice($from, $directory) && @link($from, $to)) || @copy($from, $to)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('Unable to mirror [%s] into [%s].', $from, $to));
|
||||
}
|
||||
|
||||
private static function shareDevice(string $from, string $directory): bool
|
||||
{
|
||||
$source = @stat($from);
|
||||
$target = @stat($directory);
|
||||
|
||||
return $source !== false && $target !== false && $source['dev'] === $target['dev'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<\SplFileInfo>
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,11 @@ if [ "$1" = "run" ] && [ "$2" = "list" ]; then
|
||||
fi
|
||||
|
||||
if [ "$1" = "api" ]; then
|
||||
echo 2048
|
||||
case "$2" in
|
||||
repos/*/actions/runs/*/artifacts) echo 2048 ;;
|
||||
repos/*) printf '{"default_branch":"master"}' ;;
|
||||
*) echo 2048 ;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "auth" ]; then
|
||||
[ "$GLAB_STUB_MODE" = "unauthenticated" ] && exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "api" ]; then
|
||||
case "$2" in
|
||||
*jobs\?scope*)
|
||||
case "$GLAB_STUB_MODE" in
|
||||
no-runs) exit 0 ;;
|
||||
list-404) echo "404 Not Found" >&2; exit 1 ;;
|
||||
list-network) echo "could not resolve host" >&2; exit 1 ;;
|
||||
esac
|
||||
printf '[{"name":"tia-baseline","ref":"master","pipeline":{"id":987654321}}]'
|
||||
exit 0
|
||||
;;
|
||||
*pipelines/*/jobs*)
|
||||
printf '[{"name":"tia-baseline","artifacts":[{"size":2048}]}]'
|
||||
exit 0
|
||||
;;
|
||||
projects/*)
|
||||
printf '{"default_branch":"master"}'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "job" ] && [ "$2" = "artifact" ]; then
|
||||
case "$GLAB_STUB_MODE" in
|
||||
download-403) echo "403 Forbidden" >&2; exit 1 ;;
|
||||
download-network) echo "connection refused" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
dir=""
|
||||
previous=""
|
||||
for argument in "$@"; do
|
||||
[ "$previous" = "--path" ] && dir="$argument"
|
||||
previous="$argument"
|
||||
done
|
||||
|
||||
[ -z "$dir" ] && exit 1
|
||||
|
||||
case "$GLAB_STUB_MODE" in
|
||||
missing-asset) echo "{}" > "$dir/other.json" ;;
|
||||
corrupt) printf 'not json at all' > "$dir/graph.json" ;;
|
||||
*) cp "$GLAB_STUB_PAYLOAD" "$dir/graph.json" ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
@@ -367,7 +367,7 @@ describe('buildListTestsCommand', function (): void {
|
||||
$command = $method->invoke($shard, ['bin/pest', '--update-shards'], 'custom/suite');
|
||||
|
||||
expect($command)->toBe([
|
||||
'php',
|
||||
PHP_BINARY,
|
||||
'bin/pest',
|
||||
'--update-shards',
|
||||
'--test-directory=custom/suite',
|
||||
@@ -385,7 +385,7 @@ describe('buildListTestsCommand', function (): void {
|
||||
$command = $method->invoke($shard, ['bin/pest', '--parallel', '--update-shards', '-p'], 'tests');
|
||||
|
||||
expect($command)->toBe([
|
||||
'php',
|
||||
PHP_BINARY,
|
||||
'bin/pest',
|
||||
'--update-shards',
|
||||
'--test-directory=tests',
|
||||
@@ -415,7 +415,7 @@ describe('buildListTestsCommand', function (): void {
|
||||
$command = $method->invoke($shard, ['bin/pest', '--parallel', '--processes=4', '--update-shards'], 'tests');
|
||||
|
||||
expect($command)->toBe([
|
||||
'php',
|
||||
PHP_BINARY,
|
||||
'bin/pest',
|
||||
'--update-shards',
|
||||
'--test-directory=tests',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
test('a failure in the boot files renders only that failure', function (): void {
|
||||
$process = new Process([
|
||||
'php',
|
||||
'bin/pest',
|
||||
'--test-directory=tests/Fixtures/Suites/FailingBoot',
|
||||
'--colors=never',
|
||||
], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1']);
|
||||
|
||||
$process->run();
|
||||
|
||||
expect($process->getExitCode())->toBe(1)
|
||||
->and($process->getOutput().$process->getErrorOutput())
|
||||
->toContain('The boot of the test suite failed.')
|
||||
->not->toContain('cannot be resolved');
|
||||
})->skipOnWindows();
|
||||
@@ -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, 1580 passed (3430 assertions)';
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1581 passed (3431 assertions)';
|
||||
|
||||
expect($output)
|
||||
->toContain("Tests: {$expected}")
|
||||
|
||||
Reference in New Issue
Block a user