Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"require": {
"php": "^8.3",
"composer-plugin-api": "^2.0",
"brianium/paratest": "^7.17",
"composer/composer": "^2.9",
"dg/bypass-finals": "^1.9",
"ergebnis/composer-normalize": "^2.50",
Expand Down
32 changes: 23 additions & 9 deletions src/Command/TestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ protected function configure(): void
mode: InputOption::VALUE_OPTIONAL,
description: 'Filter which tests to run based on a pattern.',
)
->addOption(
name: 'parallel',
shortcut: 'p',
mode: InputOption::VALUE_OPTIONAL,
description: 'Run tests in parallel using ParaTest. Optional number of workers.',
)
->addOption(
name: 'min-coverage',
mode: InputOption::VALUE_REQUIRED,
Expand All @@ -123,8 +129,6 @@ protected function configure(): void
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Running PHPUnit tests...</info>');

try {
$minimumCoverage = $this->resolveMinimumCoverage($input);
} catch (InvalidArgumentException $invalidArgumentException) {
Expand All @@ -134,13 +138,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$arguments = [
$this->getAbsolutePath('vendor/bin/phpunit'),
'--configuration=' . parent::getConfigFile(self::CONFIG),
'--bootstrap=' . $this->resolvePath($input, 'bootstrap'),
'--display-deprecations',
'--display-phpunit-deprecations',
'--display-incomplete',
'--display-skipped',
];

if (! $input->getOption('no-cache')) {
Expand All @@ -149,11 +148,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$coverageReportPath = $this->configureCoverageArguments($input, $arguments, null !== $minimumCoverage);

if ($input->getOption('filter')) {
if (null !== $input->getOption('filter')) {
$arguments[] = '--filter=' . $input->getOption('filter');
}

$command = new Process([...$arguments, $input->getArgument('path')]);
$parallel = null !== $input->getOption('parallel');

$command = $this->getAbsolutePath(\sprintf('vendor/bin/%s', $parallel ? 'paratest' : 'phpunit'));

if (! $parallel) {
$arguments[] = '--display-deprecations';
$arguments[] = '--display-phpunit-deprecations';
$arguments[] = '--display-incomplete';
$arguments[] = '--display-skipped';
} else {
$arguments[] = '--processes=' . ($input->getOption('parallel') ?: 'auto');
}

$output->writeln('<info>Running tests using ' . ($parallel ? 'ParaTest' : 'PHPUnit') . '...</info>');

$command = new Process([$command, ...$arguments, $input->getArgument('path')]);

$result = parent::runProcess($command, $output);

Expand Down
2 changes: 1 addition & 1 deletion tests/GitAttributes/CandidateProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#[CoversClass(CandidateProvider::class)]
final class CandidateProviderTest extends TestCase
{
private readonly CandidateProvider $provider;
private CandidateProvider $provider;

/**
* @return void
Expand Down
4 changes: 2 additions & 2 deletions tests/GitAttributes/ExistenceCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ final class ExistenceCheckerTest extends TestCase
/**
* @property ObjectProphecy<Filesystem> $filesystem
*/
private readonly ObjectProphecy $filesystem;
private ObjectProphecy $filesystem;

private readonly ExistenceChecker $checker;
private ExistenceChecker $checker;

/**
* @return void
Expand Down
2 changes: 1 addition & 1 deletion tests/GitIgnore/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#[UsesClass(GitIgnore::class)]
final class ReaderTest extends TestCase
{
private readonly Reader $reader;
private Reader $reader;

/**
* @return void
Expand Down
Loading