Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pass --testsuite when running with chunks #276

Merged
merged 9 commits into from
Oct 3, 2024
Merged
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
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is in \Paraunit\Command\ParallelCommand::addPHPUnitOptions which it should not be covered by this test case.


$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
Loading