Skip to content

Commit

Permalink
Merge pull request #276 from facile-it/regression-274
Browse files Browse the repository at this point in the history
Do not pass `--testsuite` when running with chunks
  • Loading branch information
Jean85 authored Oct 3, 2024
2 parents 31739b6 + e3cb0bc commit 76f0c9d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ jobs:
with:
dependency-versions: ${{ matrix.dependencies }}
- run: bin/phpunit --coverage-clover=coverage.xml
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
file: './coverage.xml'
token: ${{ secrets.CODECOV_TOKEN }}
files: './coverage.xml'
fail_ci_if_error: true
PHP-CS-Fixer:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased

## [1.3.1] - 2024-10-03
* Avoid passing `--testsuite` option to PHPUnit when running with chunks [#276](https://github.com/facile-it/paraunit/pull/276)

## [1.3.0] - 2022-06-15
### Added
* Add `--chunk-size` option [#164](https://github.com/facile-it/paraunit/pull/164)
Expand Down
4 changes: 4 additions & 0 deletions src/Process/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function getOptions(PHPUnitConfig $config): array
]);

foreach ($config->getPhpunitOptions() as $phpunitOption) {
if ($this->chunkSize->isChunked() && $phpunitOption->getName() === 'testsuite') {
continue;
}

$options[] = $this->buildPhpunitOptionString($phpunitOption);
}

Expand Down
21 changes: 21 additions & 0 deletions tests/Functional/Command/ParallelCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ public function testExecutionWithLogo(): void
$this->assertStringContainsString('BBBBbBBBBBBB', $output, 'Shark logo missing');
}

public function testExecutionWithChunksAndTestsuiteOption(): void
{
$application = new Application();
$application->add(new ParallelCommand(new ParallelConfiguration()));

$command = $application->find('run');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
'--configuration' => $this->getConfigForStubs(),
'--testsuite' => 'stubs',
'--chunk-size' => 2,
'--debug' => true,
]);

$output = $commandTester->getDisplay();
$this->assertStringNotContainsString('--testsuite', $output);
$this->assertStringNotContainsString('No tests executed', $output);
$this->assertStringContainsString('--configuration', $output);
}

public function testExecutionWithDebugEnabled(): void
{
$configurationPath = $this->getConfigForStubs();
Expand Down
14 changes: 14 additions & 0 deletions tests/Functional/Runner/ChunkFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@

class ChunkFileTest extends BaseIntegrationTestCase
{
public function testChunkedPlusTestSuiteOptions(): void
{
$this->setOption('chunk-size', '2');
$this->setOption('testsuite', 'stubs');
$this->setOption('debug', '1');
$this->loadContainer();

$this->executeRunner();

$output = $this->getConsoleOutput();
$this->assertStringNotContainsString('--testsuite', $output->getOutput());
$this->assertStringContainsString('--configuration', $output->getOutput());
}

public function testChunkedAllStubsSuite(): void
{
$chunkCount = 8;
Expand Down
47 changes: 45 additions & 2 deletions tests/Unit/Process/CommandLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,51 @@ public function testGetOptionsChunkedNotContainsConfiguration(): void
$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(true));
$options = $cli->getOptions($config->reveal());
$this->assertNotContains('--configuration=/path/to/phpunit.xml', $options);
foreach ($cli->getOptions($config->reveal()) as $option) {
$this->assertStringStartsNotWith('--configuration', $option);
}
}

public function testGetOptionsChunkedNotContainsTestsuite(): void
{
$config = $this->prophesize(PHPUnitConfig::class);
$config->getPhpunitOption('stderr')
->willReturn(null);

$config->getFileFullPath()
->willReturn('/path/to/phpunit.xml');

$incompatibleOption = new PHPUnitOption('testsuite');
$incompatibleOption->setValue('foo');
$config->getPhpunitOptions()
->willReturn([$incompatibleOption]);

$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(true));
foreach ($cli->getOptions($config->reveal()) as $option) {
$this->assertStringStartsNotWith('--testsuite', $option);
}
}

public function testGetOptionsNotChunkedContainsTestsuite(): void
{
$config = $this->prophesize(PHPUnitConfig::class);
$config->getPhpunitOption('stderr')
->willReturn(null);

$config->getFileFullPath()
->willReturn('/path/to/phpunit.xml');

$incompatibleOption = new PHPUnitOption('testsuite');
$incompatibleOption->setValue('foo');
$config->getPhpunitOptions()
->willReturn([$incompatibleOption]);

$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(false));
$this->assertContains('--testsuite=foo', $cli->getOptions($config->reveal()));
}

private function mockChunkSize(bool $enabled): ChunkSize
Expand Down

0 comments on commit 76f0c9d

Please sign in to comment.