mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14a3efd918 | |||
| 8b6607e344 | |||
| 94f4f1ff48 | |||
| f0dd0d4d85 | |||
| 4b4474dd77 |
+5
-5
@@ -18,20 +18,20 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.4",
|
||||
"brianium/paratest": "^7.24.1",
|
||||
"brianium/paratest": "^7.25.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.3",
|
||||
"symfony/process": "^8.1.6"
|
||||
"phpunit/phpunit": "^13.3.6",
|
||||
"symfony/process": "^8.1.7"
|
||||
},
|
||||
"conflict": {
|
||||
"filp/whoops": "<2.18.3",
|
||||
"laravel/boost": "<2.6.0",
|
||||
"phpunit/phpunit": ">13.3.3",
|
||||
"phpunit/phpunit": ">13.3.6",
|
||||
"sebastian/exporter": "<7.0.0",
|
||||
"webmozart/assert": "<1.11.0"
|
||||
},
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest-dev-tools": "^5.0.0",
|
||||
"pestphp/pest-plugin-browser": "^5.0.1",
|
||||
"pestphp/pest-plugin-browser": "^5.1.0",
|
||||
"pestphp/pest-plugin-phpstan": "^5.2.1",
|
||||
"pestphp/pest-plugin-rector": "^5.0.4",
|
||||
"pestphp/pest-plugin-type-coverage": "^5.0.2",
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '5.2.0';
|
||||
return '5.3.0';
|
||||
}
|
||||
|
||||
function testDirectory(string $file = ''): string
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Pest\Plugins\Tia\Baselines;
|
||||
|
||||
use Pest\Plugins\Tia\WatchPatterns;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
@@ -38,10 +39,7 @@ abstract readonly class BaseRemote // @pest-arch-ignore-line
|
||||
|
||||
public function cliExists(): bool
|
||||
{
|
||||
$process = new Process(['which', $this->cliName()]);
|
||||
$process->run();
|
||||
|
||||
return $process->isSuccessful();
|
||||
return new ExecutableFinder()->find($this->cliName()) !== null;
|
||||
}
|
||||
|
||||
public function cliAuthenticated(): bool
|
||||
|
||||
@@ -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']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Pest Testing Framework 5.2.0.
|
||||
Pest Testing Framework 5.3.0.
|
||||
|
||||
USAGE: pest <file> [options]
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
Pest Testing Framework 5.2.0.
|
||||
Pest Testing Framework 5.3.0.
|
||||
|
||||
|
||||
@@ -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();
|
||||
@@ -519,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>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user